Skip to main content
The SnackBase SDK provides React hooks and context providers for seamless integration with React applications.

Installation

Install the SDK and React peer dependency:
npm
yarn
pnpm
React 18 or higher is required for the React integration.

Setup

1. Wrap with Provider

Wrap your application with SnackBaseProvider:

2. Use Hooks

Use the provided hooks in your components:

Provider Props

Environment-Specific Setup

Development

Production

With Next.js

App Router

Pages Router

With Vite

Access Client Directly

For advanced use cases, access the client directly:

Server-Side Rendering

For SSR, skip provider on server:

TypeScript Support

The React integration is fully typed:

Complete Example

Next Steps