An application showing how to embed Apache Superset dashboards using the @superset-ui/embedded-sdk.
- Three-panel resizable layout: Configuration panel, embedded dashboard, and event log
- SDK version resilience: Automatically detects available SDK features and gracefully handles missing methods
- Monaco Editor: JSON editors for RLS rules and UI configuration with syntax highlighting
- Real-time event logging: Monitor SDK events and method responses
- Guest token authentication: Securely authenticate with Superset using admin credentials
- Tooltips: Comprehensive help text for all configuration options
- Node.js 18+ and npm
- A running Superset instance with:
- Embedded dashboard configuration enabled
- A dashboard configured for embedding
- Admin user credentials
# Install all dependencies (root, client, and server)
npm installRun both frontend and backend concurrently:
npm run devOr run them separately:
# Terminal 1: Run frontend (http://localhost:3000)
npm run dev:client
# Terminal 2: Run backend (http://localhost:3001)
npm run dev:servernpm run buildCreate a .env file in the root directory (optional):
# Server port (default: 3001)
PORT=3001
NODE_ENV=development
# ==========================================
# JWT Authentication (Optional)
# ==========================================
# When configured, the server will generate guest tokens locally
# instead of requesting them from Superset's API.
# This is useful when running behind an authenticating reverse proxy.
# Path to a file containing the JWT signing secret (preferred)
GUEST_TOKEN_SECRET_FILE=/path/to/secret
# Or provide the secret inline (for development only)
GUEST_TOKEN_SECRET=your-secret-key
# JWT audience claim (optional, must match Superset's GUEST_TOKEN_JWT_AUDIENCE)
GUEST_TOKEN_AUDIENCE=https://superset.example.com
# Token expiration in seconds (default: 300 = 5 minutes)
GUEST_TOKEN_EXPIRATION_SECONDS=300
# HTTP header name for authenticated username
# Set by the reverse proxy after authentication
JWT_USERNAME_HEADER=x-username
# ==========================================
# Pre-configured Domains (Optional)
# ==========================================
# When set, these values are used automatically and the corresponding
# UI inputs are hidden from the configuration panel.
# Superset frontend domain (where the iframe loads from)
SUPERSET_FRONTEND_DOMAIN=http://localhost:9000
# Superset API domain (where tokens are requested from)
SUPERSET_API_DOMAIN=http://localhost:8088
# Permalink domain (for resolving dashboard permalinks)
PERMALINK_DOMAIN=http://localhost:9000The application supports two authentication modes:
1. Superset API Authentication (Default)
- User enters Superset username/password in the UI
- Server requests guest tokens from Superset's
/api/v1/security/guest_token/endpoint
2. JWT Signing (When GUEST_TOKEN_SECRET or GUEST_TOKEN_SECRET_FILE is set)
- Server generates guest tokens locally using a shared secret
- Username is obtained from an HTTP header (set by reverse proxy)
- No credentials UI is shown to the user
- Enable embedded dashboards in your Superset instance
- Configure a dashboard for embedding (get the embed ID)
- Ensure your user has
can_grant_guest_tokenpermission - Note your dashboard's UUID
- Start the application: Run
npm run dev - Open your browser: Navigate to http://localhost:3000
- Configure connection (if not pre-configured via environment variables):
- Enter your Superset frontend domain (e.g., http://localhost:9000)
- Enter your Superset API domain (e.g., http://localhost:8088)
- Enter username and password (unless JWT auth is enabled)
- Configure dashboard:
- Enter the dashboard embed ID (from Superset's embed configuration)
- Configure options (optional):
- Add RLS rules as JSON array
- Customize UI config as JSON object
- Click "Apply Configuration" to embed the dashboard
- Monitor events: View SDK events and responses in the right panel
- Test SDK methods: Use the buttons in the event panel to call SDK methods
superset-embedded-demo/
├── client/ # React frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── services/ # API client
│ │ ├── styles/ # CSS styles
│ │ ├── types/ # TypeScript types
│ │ ├── App.tsx # Main app component
│ │ └── main.tsx # Entry point
│ └── package.json
├── server/ # Express backend
│ ├── src/
│ │ ├── middleware/ # Express middleware
│ │ ├── routes/ # API routes
│ │ ├── services/ # Business logic
│ │ └── index.ts # Entry point
│ └── package.json
└── package.json # Workspace root
## SDK Methods Demonstrated
- `embedDashboard()`: Embed a dashboard in an iframe
- `observeDataMask()`: Listen for filter changes
- `getDataMask()`: Get current filter state
- `getChartStates()`: Get state of all charts
- `getActiveTabs()`: Get currently active tabs
- `getScrollSize()`: Get dashboard dimensions
- `getDashboardPermalink()`: Get permalink URL
- `unmount()`: Remove the embedded dashboard
## Development
### Using a Local SDK
To test with a local version of `@superset-ui/embedded-sdk`:
```bash
# In client/package.json, replace:
"@superset-ui/embedded-sdk": "^0.3.0"
# With the path to your local SDK:
"@superset-ui/embedded-sdk": "file:../../superset/superset-embedded-sdk"
# Then reinstall dependencies
npm install
MIT
