Skip to main content

Installation

The Bloque SDK is available as an npm package and can be installed using any modern JavaScript package manager.

Package Managers

npm install @bloque/sdk

Requirements

Runtime Support

The SDK supports multiple JavaScript runtimes:
  • Node.js 22.x or higher
  • Bun 1.x or higher
  • Deno Latest version
  • Browsers Modern browsers with ES2020+ support
  • React Native Latest stable version
The SDK uses modern JavaScript features and requires ES2020+ support.

TypeScript

While the SDK is written in TypeScript and includes full type definitions, TypeScript is optional for your project:
  • TypeScript 5.x or higher (recommended)
  • Type definitions are included automatically
  • Full IntelliSense support in VS Code and other editors

Monorepo Packages

The Bloque SDK is a monorepo containing multiple packages. The main @bloque/sdk package aggregates all functionality, but you can also install individual packages if needed:
For most use cases, install only @bloque/sdk. The individual packages are primarily for advanced modular setups.

Version Pinning

The SDK is under active development. We strongly recommend pinning to a specific version to avoid unexpected breaking changes.
In your package.json:
package.json
{
  "dependencies": {
    "@bloque/sdk": "0.0.43"
  }
}
Avoid using version ranges like ^0.0.43 or ~0.0.43 during the pre-1.0 phase.

Verifying Installation

After installation, verify the SDK is working:
import { SDK } from '@bloque/sdk';

console.log('Bloque SDK imported successfully!');

Platform-Specific Setup

Node.js

No additional setup required. Node.js 22+ automatically loads .env files.
import { SDK } from '@bloque/sdk';

const bloque = new SDK({
  origin: process.env.BLOQUE_ORIGIN!,
  auth: {
    type: 'apiKey',
    apiKey: process.env.BLOQUE_API_KEY!,
  },
  mode: 'production',
  platform: 'node', // optional, auto-detected
});

Bun

Bun automatically loads .env files without additional configuration:
import { SDK } from '@bloque/sdk';

const bloque = new SDK({
  origin: process.env.BLOQUE_ORIGIN!,
  auth: {
    type: 'apiKey',
    apiKey: process.env.BLOQUE_API_KEY!,
  },
  mode: 'production',
  platform: 'bun',
});

Deno

Use npm specifiers or import maps:
import { SDK } from 'npm:@bloque/sdk';

const bloque = new SDK({
  origin: Deno.env.get('BLOQUE_ORIGIN')!,
  auth: {
    type: 'apiKey',
    apiKey: Deno.env.get('BLOQUE_API_KEY')!,
  },
  mode: 'production',
  platform: 'deno',
});

Browser

For browser environments, use JWT authentication instead of API keys:
import { SDK } from '@bloque/sdk';

const bloque = new SDK({
  auth: {
    type: 'jwt',
  },
  mode: 'production',
  platform: 'browser',
});

// Authenticate with JWT
const session = await bloque.authenticate();
Never expose API keys in browser code. Use JWT authentication for client-side applications.

React Native

Install the SDK and configure secure token storage:
npm install @bloque/sdk
npm install @react-native-async-storage/async-storage
Implement token storage:
import { SDK } from '@bloque/sdk';
import AsyncStorage from '@react-native-async-storage/async-storage';

const tokenStorage = {
  get: async () => await AsyncStorage.getItem('bloque_token'),
  set: async (token: string) => await AsyncStorage.setItem('bloque_token', token),
  clear: async () => await AsyncStorage.removeItem('bloque_token'),
};

const bloque = new SDK({
  auth: {
    type: 'jwt',
  },
  mode: 'production',
  platform: 'react-native',
  tokenStorage,
});

Build Output

The SDK ships with multiple module formats:
  • ESM (ES Modules): dist/index.js - For modern bundlers and Node.js
  • CommonJS: dist/index.cjs - For legacy Node.js require()
  • TypeScript Declarations: dist/index.d.ts - Full type definitions
Modern bundlers like Vite, Webpack 5+, and esbuild will automatically use the ESM version.

Troubleshooting

Make sure you’ve installed the package:
npm install @bloque/sdk
If using TypeScript, verify your tsconfig.json has "moduleResolution": "bundler" or "node16".
Ensure you’re using TypeScript 5.x or higher:
npm install -D typescript@latest
Verify your Node.js version:
node --version  # Should be 22.x or higher
Upgrade if needed:
nvm install 22
nvm use 22
This usually happens when:
  • The package wasn’t installed correctly
  • Your node_modules folder is corrupted
Solution:
rm -rf node_modules package-lock.json
npm install

Next Steps

Quickstart

Get started with your first API call

Authentication

Learn about API keys and JWT authentication

Build docs developers (and LLMs) love