The @basedash/embed SDK is the recommended way to embed Basedash in a React application. It wraps the existing iframe integration with typed components and provides server-only helpers for creating authentication tokens.
Use the SDK to embed:
- AI chat
- The interactive dashboards workspace
- Insights
- Automations
- The full Basedash app with selected features
- A read-only shared dashboard
The SDK is open source at github.com/Basedash/embed.
Install the SDK
The SDK supports React 18.2 and React 19.
Before you start
- Go to Settings → Embedding and enable full app embedding.
- Add your application’s production origins to the allowed origins list.
- Copy your JWT secret from Settings → Security.
- Store the secret in your server environment. Never expose it to browser code or a public environment variable.
You also need your Basedash organization ID. If you provision customer organizations through the Basedash API, create them with fullEmbedEnabled: true and store the returned organization ID and JWT secret on your server.
Create a token endpoint
Your backend must authenticate the current user, confirm that they can access the customer organization, and create a short-lived Basedash token.
createEmbedToken signs an HS256 JWT and defaults to a 10-minute expiration. The token identifies the user and organization. Basedash creates the user and organization membership on their first authenticated embed load.
Only import createEmbedToken from @basedash/embed/server in trusted server
code. Anyone with your JWT secret can impersonate users in that Basedash
organization.
Add the provider
In your React application, fetch the token from your backend and pass the callback to BasedashProvider.
The provider fetches one token per mount. Components beneath the same provider reuse it.
If your React tree already receives a server-generated token, pass it directly:
You can also pass token directly to an individual component without a provider.
Choose a component
Chat
BasedashChat shows AI chat and hides the other primary Basedash features. It hides the organization name by default.
Dashboards
BasedashDashboards shows the interactive dashboards workspace, including dashboard and chart creation, and hides the other primary features.
Insights
BasedashInsights shows insights and hides the other primary features.
Insights must be enabled for the organization.
Automations
BasedashAutomations shows automations and hides the other primary features.
Automations must be enabled for the organization.
Full app
BasedashApp shows the complete embed by default. Use props to select which features remain available.
The supported configuration props are:
theme: light, dark, or auto
hideOrgName
hideChat
hideDashboards
hideInsights
hideAutomations
hideSuggestedPrompts
At least one of chat, dashboards, insights, or automations must remain visible. If all four are hidden, Basedash falls back to chat.
Shared dashboard
BasedashSharedDashboard renders a read-only dashboard from a public sharing link. It does not require a provider or user token.
Enable sharing from the dashboard’s Share menu and use the ID from the resulting /shared/{id} URL.
Lock shared dashboard filters
For customer-specific or user-specific shared dashboards, create a secure filter token on your server.
Pass the result to the shared dashboard:
Locked filters are applied server-side, hidden from viewers, and cannot be changed in the browser. See secure filtering for filter behavior and security considerations.
Customize the frame
All components accept:
className and style for the outer container
iframeProps for the underlying iframe
loadingFallback, shown until the iframe loads
errorFallback, shown if token fetching fails
title for the iframe’s accessible name
instanceUrl for self-hosted Basedash
The iframe defaults to full width and height, no border, allow="clipboard-write", and eager loading.
Handle token errors
Use errorFallback to keep an authentication failure inside your page layout:
The useBasedash() hook exposes the current token, status, error, and a refreshToken() method for custom controls.
Self-hosted Basedash
Set instanceUrl on the provider:
Server-side token generation is the same for cloud and self-hosted instances.
Non-React applications
For Vue, Svelte, server-rendered HTML, or other applications, use the raw iframe integration. The framework-independent buildEmbedUrl helper is also available from @basedash/embed if your project uses JavaScript or TypeScript without React.
Current limitations
- SDK components render Basedash through iframes; they do not render Basedash UI natively.
- Auto-resizing, navigation callbacks, and host-triggered actions are not available because Basedash does not currently expose an iframe messaging API.
- Shared dashboards are supported, but Basedash does not currently expose standalone shared-chart embeds.
Related pages