Skip to main content
Try it and see the code. embed.lightdash.com is an interactive demo and helper that lets you preview embedded content and generate a JWT for your own project. For a working end-to-end example, see the example embed app on GitHub — a Node.js app that mints tokens server-side and renders a Lightdash dashboard.

Overview

The Lightdash React SDK (@lightdash/sdk) provides React components for embedding Lightdash content in your React or Next.js applications. The SDK offers advantages over iframe embedding:
  • Seamless integration with your React application
  • Programmatic filters for dashboards
  • Callbacks for user interactions (e.g., explore navigation)
  • Custom styling to match your application
  • TypeScript support with full type definitions
For iframe embedding, see the embedding reference.

Set up CORS

To use the React SDK, you need to update your “Cross-Origin Resource Sharing” (CORS) policy so the domain hosting your React app is allowed to call the Lightdash API. In Lightdash, go to Project settings -> Embed configuration -> CORS and add each origin where you’ll use the SDK.
CORS settings panel showing regex and exact origin entries
Use origin mode for exact origins and simple subdomain wildcards:
  • https://app.example.com allows only that exact origin.
  • *.example.com allows HTTPS subdomains like https://app.example.com and is saved as a regex pattern.
Use regex mode (.*) for advanced patterns. Enter the pattern body only; Lightdash matches the whole origin automatically. For example, https:\\/\\/.*\\.example\\.com allows subdomains of example.com.
Only add origins you control. Avoid broad patterns that could match arbitrary external domains.
For self-hosted deployments, you can also configure instance-level allowed origins with environment variables:
CORS is enabled by default. Set LIGHTDASH_CORS_ENABLED=false only if you want to disable CORS for the whole instance. Browsers enforce a Same-Origin Policy that blocks a web application from making requests to a domain other than the one that served it. Because the React SDK calls the Lightdash API from your frontend, your instance has to name your application’s origin in its CORS configuration for those requests to go through.
CORS is only required for the React SDK. iframe embedding does not require CORS configuration.

Installing the Lightdash SDK

In your frontend project, use your preferred package manager to install the SDK.
At the moment, we support React 18 and 19, so make sure your frontend is using React 18 or later. For Next.js, version 15 or later is required.

Import CSS styles

The Lightdash SDK requires CSS styles to render components correctly. Import the SDK’s CSS file as the first import in your React application’s entry point:
The CSS import must be the first import in your entry file to ensure Lightdash styles load before other styles and avoid conflicts.

Components and hooks

The Lightdash SDK exports components for embedding Lightdash content and hooks for building custom host-app UI around embedded content:
  • Lightdash.Dashboard - Embed complete dashboards with multiple tiles
  • Lightdash.DashboardBuilder - Let embedded users create a brand-new dashboard
  • Lightdash.Chart - Embed individual saved charts
  • Lightdash.Explore - Embed interactive data exploration interface
  • Lightdash.AiAgent - Embed an AI agent so users can chat with their data
  • Lightdash.MetricsCatalog - Embed the project metrics catalog so users can browse and explore metrics
  • Lightdash.useLightdashContent - List spaces, dashboards, charts, and data apps for a custom content catalog
  • Lightdash.useLightdashAiAgentThreads - List an embed user’s previous AI agent threads to build a thread history UI
All components share common props for authentication and styling.

Lightdash.Dashboard

Embed complete Lightdash dashboards with multiple visualizations, filters, and interactive features. See Embedding dashboards for the JWT claims that control what viewers can do.

Props

Basic usage

With filters

Apply filters programmatically using the filters prop:
See Filtering data for complete filter documentation.

With styling

With explore callback

Track when users navigate to explore:

With edit mode

When the JWT includes a writeActions claim, you can render an existing dashboard in edit mode and let users rename it, add saved charts from the allowed space, move or resize tiles, and save changes. The host app controls the edit-mode state through isEditMode and onEditModeChange.
Add-tile content is filtered to the JWT writeActions.spaceUuid, so users can only pick saved charts from the allowed space. See Write actions for the JWT claim.

Lightdash.DashboardBuilder

Let embedded users build a brand-new dashboard from scratch. On mount, the SDK creates an empty dashboard in the JWT writeActions.spaceUuid and renders it through the same embedded dashboard component as Lightdash.Dashboard. The host app controls when the dashboard is in edit mode. Use this when you want your customers to author their own dashboards inside your app — for example, a “Create dashboard” page in your customer portal — without giving them a Lightdash login.

Props

Basic usage

Requirements and behavior

  • The JWT must include a writeActions claim with spaceUuid. JWTs without writeActions fail closed for write-capable paths.
  • The new dashboard is created in writeActions.spaceUuid, named “Untitled dashboard”, and is empty.
  • Add-tile content (saved charts and SQL charts) is filtered to the same space.
  • Dashboards created or edited through the SDK are normal Lightdash dashboards — they can be viewed and edited from Lightdash and vice versa.
  • See Write actions for the JWT claim and how to configure the actor and destination space.

Lightdash.Chart

Embed individual saved charts for focused, single-metric displays with minimal UI.

Props

Unlike Dashboard, Chart does not support filters or onExplore props since charts are read-only and cannot navigate to explore.

Basic usage

With styling

Token generation for charts

Charts require a JWT with type: 'chart':
See Embedding charts guide for details.

Lightdash.Explore

Embed interactive data exploration interface with full query builder capabilities.

Props

Basic usage

With styling

Token generation for explores

Explores require canExplore: true in the JWT:

Lightdash.AiAgent

Embed a Lightdash AI agent so embedded users can chat with their data, generate charts, and save results back to a fixed space — without a Lightdash login. The component renders the agent inside an iframe. Use threadUuid to deep-link into an existing thread, or omit it to land on the new-thread screen.

Props

Lightdash.AiAgent does not accept filters, contentOverrides, uiOverrides, or onExplore. Threads, navigation, and chart actions are managed inside the embedded agent UI.
onThreadChange fires whenever the embedded agent creates a new thread or opens an existing one. Use it together with threadUuid to persist the current conversation in your app (for example in localStorage or your own backend) and resume it the next time the user returns. Under the hood, the SDK passes a targetOrigin query parameter to the iframe and listens for lightdash:aiAgentThreadChanged postMessage events from the embedded page — no extra setup is required on your side.

Basic usage

Open a specific thread

Pass threadUuid to deep-link the embed into a specific conversation on mount:

Persist and resume the last conversation

Combine threadUuid and onThreadChange to keep users on their most recent thread across page reloads. This example stores the latest thread UUID in localStorage:

Token generation for AI agents

AI agent embeds require a JWT with content.type: 'aiAgent' and a writeActions claim that pins the destination space and the actor used for agent queries and chart saves:
See Embedding AI agents for the full guide and AI agent token for the complete JWT structure.

Lightdash.MetricsCatalog

Embed the Lightdash metrics catalog so embedded users can browse the metrics defined in a project, preview them, and — when the JWT allows it — continue into Explore without leaving your app. The component renders the catalog inside an iframe. When a viewer clicks Explore from here on a metric, the SDK swaps in an embedded Explore view; a Back action returns them to the catalog.

Props

Lightdash.MetricsCatalog does not accept filters, contentOverrides, uiOverrides, or onExplore. The catalog and the embedded Explore it launches are managed inside the component.

Basic usage

Token generation for the metrics catalog

Metrics catalog embeds require a JWT with content.type: 'metricsCatalog' and a projectUuid. Set content.canExplore to true to let embedded users open Explore from a metric, and include a writeActions claim if you want them to save the resulting charts back to Lightdash.
Omit canExplore (or set it to false) to publish a read-only browse experience. See Embedding the metrics catalog for the full guide and Metrics catalog token for the complete JWT structure.

API hooks

Lightdash.useLightdashContent

Use useLightdashContent when you want your own app to list Lightdash content instead of embedding the Lightdash home page. A common pattern is to let customers choose a space in your UI, show the dashboards and charts in that space, then render the selected object with Lightdash.Dashboard or Lightdash.Chart. The hook calls the Lightdash content API and returns metadata only. It does not render the selected chart or dashboard, and it does not replace the chart or dashboard embed token you pass to the render component.

Backend: generate an API access token

Generate the token on your backend with your Lightdash embed secret. Never expose the embed secret in browser code.
The service account controls what the hook can list. If the service account cannot view a private space, content from that space is not returned.

Frontend: list content in a space

Options

Use the spaceUuids option as a filter, not as an authorization boundary — authorization comes from the API access token’s service account permissions. apiAccess tokens are for API reads such as content listing; to let embedded users save charts or dashboards, use an embed token that supports writeActions.

Lightdash.useLightdashAiAgentThreads

Use useLightdashAiAgentThreads when you want to show your users a list of their previous AI agent conversations — for example a “Recent chats” sidebar next to a Lightdash.AiAgent embed. The hook calls the AI agent threads endpoint with the embed JWT, so it returns only threads that belong to the JWT-authenticated embed user and are scoped to their embed space. Pair it with Lightdash.AiAgent’s threadUuid and onThreadChange props to let users resume any past conversation.

Options

The hook takes the same LightdashApiClientConfig as useLightdashContent, with auth.type: 'embedToken' and the AI agent embed JWT as the token.

Types

Example: thread history + resume

useLightdashAiAgentThreads uses the same embed JWT you pass to Lightdash.AiAgent. The token’s content.agentUuid and writeActions.spaceUuid are what scope the returned threads — the hook cannot list threads from a different agent or space, even if you pass a different agentUuid argument.

Generating embed tokens

All SDK components require JWTs generated server-side, signed with the embed secret from embed setup. Here’s a complete example, including user attributes for row-level filtering:

Backend API endpoint

Frontend React component

To ensure security, JWT generation code must run in your backend, and the Lightdash embed secret must never be exposed in frontend code. This prevents unauthorized access and protects sensitive data.

Applying styles

Override styles within Lightdash components to match your application’s design.

Supported style overrides

Both properties accept normal CSS values and are set on a styles object passed to any component.

Font family

Sets the font family for all text within the embedded content. Font sizes and other properties are preserved.
Some charts and components set font-family explicitly, so the fontFamily style is applied with higher specificity to override these.

Background color

Sets the background for the embedded content. Can be any color value or 'transparent'.

Complete example

CSS class overrides

Beyond the styles prop, you can target embedded dashboard elements directly from your application’s stylesheet. Each element below carries a stable, human-readable classname that is part of the SDK’s public API — it won’t change when internal layout does, so your overrides stay resilient across releases.
The filter, date-zoom, and parameter dropdowns render in a portal at the page root — outside the dashboard container — so target them with a global selector rather than as a descendant of the embedded dashboard.

Light and dark mode

Use the theme prop to render embedded content in either 'light' or 'dark' mode. This is typically driven by the host application’s own theme state, so the embedded dashboard, chart, or explore matches the surrounding UI.
The theme prop is supported on Lightdash.Dashboard, Lightdash.Chart, and Lightdash.Explore.
When theme is set, the SDK forces the Mantine color scheme and ignores any user-toggled preference stored in the embed. Omit the prop to let the embed use its default (light) color scheme.

Syncing with your app’s theme

Pass your app’s current theme value directly to the SDK so the embed re-renders when it changes:

Combining with styles.backgroundColor

When theme is set, the embed uses the matching Mantine body background by default. If you also pass styles.backgroundColor, your value takes precedence:

Color palettes

You can customize the appearance of embedded dashboards using color palettes. Define multiple color palettes in your organization settings, then apply them to embedded dashboards using the paletteUuid prop. For more on customizing appearance, see customizing the appearance of your project.

Setting up color palettes

  1. Go to Organization settings > Appearance in Lightdash
  2. Define one or more color palettes
  3. Copy the palette UUID for the palette you want to use (or fetch from API GET /api/v1/org/color-palettes)

Applying a palette

Pass the paletteUuid prop to the Lightdash.Dashboard component:

Filtering data

Filters can be passed to <Lightdash.Dashboard/> to filter dimensions by values. Filters are applied as AND operations, each further restricting results. The Chart and Explore components do not support the filters prop.
For the filters prop to work, your JWT must have dashboardFiltersInteractivity set to enabled: 'all'. Without this configuration, filters will not be applied.

Filter structure

Basic example

Multiple filters

Filters are applied as AND operations:

FilterOperator enum

Import FilterOperator from the SDK:
Available operators:

Available fields

Only fields that are available for filtering can be filtered. These are specified in the JWT passed to the SDK.
To generate tokens with filterable fields, configure your embed in the Lightdash UI or include the appropriate fields in your JWT structure.

Localization

The React SDK has two translation props, split by what they translate: There is no locale setting and no bundled language packs. Your app owns locale state and passes the translated strings for the language it wants. Anything you don’t override renders in the built-in English. Both props are accepted by Lightdash.Dashboard, Lightdash.DashboardBuilder, Lightdash.Chart, and Lightdash.Explore. They are React SDK props only; iframe embeds are not translatable.

Translating your content with contentOverrides

contentOverrides translates the content you author in Lightdash: dashboard names and descriptions, tile titles, chart names, axis labels, series names, and markdown content. Recommended tools:
  • Translation maps – The Lightdash CLI can generate translation maps when downloading content as code
  • Runtime translation management – Use a translation library like i18next
  • Translation production tools – Tools like Locize help manage translations efficiently

Video overview

Translation maps

The Lightdash CLI can produce translation maps for dashboards and charts. To include translation maps when downloading content, add the --language-map flag:
Alongside each downloaded dashboard and chart, there will be a <file name>.language.map.yml file containing translatable strings. Example translation map:
These translation maps can be imported into tools like Locize to begin translation.

Runtime translation

At runtime, pass a translation object to the SDK’s contentOverrides prop. We suggest using i18Next to load translations:

Setting up i18Next with Locize

Translating the Lightdash UI with uiOverrides

uiOverrides translates the interface Lightdash renders around your content: filter operators and inputs, the add/edit filter popover, the date zoom control, tile menus, and dashboard export buttons. Pass a flat object mapping keys to translated strings. The key set is exported as the TypeScript type SdkUiOverrides from @lightdash/sdk, so editors autocomplete every key and unknown keys are compile errors.
Both the @lightdash/sdk package and your Lightdash instance must be on a version that includes uiOverrides. If you self-host, upgrade your instance as well, since the strings render inside Lightdash’s UI. There is no feature flag; uiOverrides is available wherever embedding is available.

Available keys

Keys are flat dot-paths, namespaced by the surface they translate:
  • filters.* – operator labels (including date-specific variants), units of time, filter pills, the add/edit filter popover, value inputs, autocomplete states, the collapsed filter-bar summary, cross-filtering menu items, and the required-filters flow viewers see
  • dateZoom.* – the date zoom control, granularity names, tooltips, and the per-tile zoom indicator
  • tileMenu.* – the tile menu: Explore from here, Download data, Export image, View underlying data
  • dashboard.* – dashboard-level export and print buttons
Every key is also exported through the SdkUiOverrides type in @lightdash/sdk, so your editor autocompletes the full set. The complete list with the built-in English defaults:
A quick way to create a new translation: copy one of the examples above and ask an AI agent to translate the values into your target language. Keep the keys and any {token} placeholders unchanged, then review the output before shipping it.

Key rules

  • Every key is optional. Partial dictionaries are fine; missing keys render in English.
  • Keys are a stable, additive contract. Existing keys are never renamed or removed across SDK versions. New UI may add keys, which fall back to English until you translate them.
  • Keep {token} placeholders. Some values contain placeholders that Lightdash fills at runtime, like 'filters.autocomplete.addValue': 'Add "{value}"' or 'filters.crossFilter.menuLabel': 'Filter dashboard on {field} to'. Keep the token, with its exact name in braces, somewhere in the translation. Its position is free. No other syntax is supported (not ICU MessageFormat).
  • Plurals are one key per form. Count-dependent strings exist as separate keys, like filters.summary.filterSingular / filters.summary.filterPlural, and units of time with .singular / .plural / .completedSingular / .completedPlural variants. There are no CLDR plural rules, so languages with more than two plural forms can only approximate.

Using uiOverrides with an i18n framework

Because the map is flat JSON, it drops directly into i18next-style resource files. Keep a uiOverrides object per locale and pass the active one:
Re-mounting the component on language change (the key prop) is the simplest way to re-render every string.

What can be translated

Not translatable:
  • Data from your warehouse – string values in charts, dimension values, and raw table data render as they exist in your database
  • Field and table names – dimension and metric labels shown on filter pills and in the field picker come from your dbt schema
  • Date picker internals – month and weekday names inside calendar popups render in English
  • Data formatting – numbers, dates, and currencies render per chart config
  • Editor-only UI – dashboard edit mode is not translated

Complete example

Here’s a full example integrating everything:

Backend (Express + Node.js)

Frontend (React)