Skip to main content

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. This is done using environment variables. For Lightdash Cloud customers, contact the Lightdash team to update these for you.
Why CORS is neededEnabling CORS (Cross-Origin Resource Sharing) is necessary because browsers enforce security policies that prevent web applications from making requests to a different domain than the one that served the app (known as the Same-Origin Policy).Since the Lightdash React SDK interacts with a Lightdash API, you need to configure CORS on your Lightdash instance to allow your frontend application to communicate with the Lightdash server without being blocked by the browser.
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

The Lightdash SDK exports three components for embedding different content types:
  • Lightdash.Dashboard - Embed complete dashboards with multiple tiles
  • Lightdash.Chart - Embed individual saved charts
  • Lightdash.Explore - Embed interactive data exploration interface
All components share common props for authentication and styling.

Lightdash.Dashboard

Embed complete Lightdash dashboards with multiple visualizations, filters, and interactive features.

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:

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:

Generating embed tokens

All SDK components require JWTs generated server-side. Here’s a complete example:

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

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.
Filtering is only available for Dashboard components. 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 Lightdash SDK supports multilingual translation using standard i18n translation objects. To display a translated Lightdash dashboard, pass a correctly formatted translation object to the SDK.
  • 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

What can be translated

Can be translated (UI strings specified in Lightdash):
  • Dashboard names and descriptions
  • Tile titles
  • Chart names
  • Axis labels
  • Series names
  • Markdown content
Cannot be translated (data from your warehouse):
  • String values in charts
  • Dimension values
  • Metric names from database
  • Raw data in tables
Strings originating from your data warehouse cannot be translated by the SDK. They are presented as they exist in your database.

Complete example

Here’s a full example integrating everything:

Backend (Express + Node.js)

Frontend (React)

See also

Embedding quickstart

Get started with embedding in 5 minutes

Embedding API reference

Complete JWT structure and configuration

iframe embedding reference

Complete iframe URL patterns and HTML embedding

Embedding dashboards

Complete guide to dashboard embedding

Embedding charts

Complete guide to chart embedding

User attributes

Implement row-level security with user attributes