Skip to main content
The SnackBase JavaScript SDK provides a type-safe, feature-complete interface for interacting with SnackBase from JavaScript and TypeScript applications.

Prerequisites

Before installing the SDK, ensure you have:
  • Node.js 18+ or a compatible runtime
  • npm, yarn, or pnpm for package management
  • A SnackBase instance (local or hosted)

Installation

npm

npm
npm install @snackbase/sdk

yarn

yarn
yarn add @snackbase/sdk

pnpm

pnpm
pnpm add @snackbase/sdk

React Integration

If you’re using React, you’ll also need React installed as a peer dependency:
npm
npm install @snackbase/sdk react
The React integration is exported from the same package (@snackbase/sdk/react) and requires React 18 or higher.

Platform Support

The SDK works across multiple JavaScript environments:
PlatformSupport LevelNotes
Modern BrowsersFullChrome, Firefox, Safari, Edge
React NativeFullUses AsyncStorage for tokens
Node.js 18+FullServer-side rendering, APIs
Next.jsFullBoth App and Pages routers
Vue/NuxtFullVia the core SDK
Svelte/SvelteKitFullVia the core SDK

TypeScript Support

The SDK is written in TypeScript and includes full type definitions. No additional @types packages are needed.
import { SnackBaseClient } from "@snackbase/sdk";

// Full autocomplete and type safety
const client = new SnackBaseClient({
  baseUrl: "https://your-project.snackbase.dev",
});

Bundle Size

The SDK is optimized for production use:
  • Core SDK: 14.87 KB (gzipped)
  • React Integration: 1.42 KB (gzipped)
  • Total: 16.29 KB (gzipped)

Verification

After installation, verify the SDK is working:
import { SnackBaseClient } from "@snackbase/sdk";

const client = new SnackBaseClient({
  baseUrl: "https://your-project.snackbase.dev",
});

console.log("SnackBase SDK version:", client.getConfig().version);

Next Steps