Live Demo: https://embed-demo.minusx.ai
This repo demonstrates how to add MinusX support to an application that embeds Metabase dashboards and questions. The proxy server handles injecting the MinusX js and custom css into the Metabase iFrame. With that, MinusX just works exactly like it does in the browser extension.
Follow these steps to set up and run the embedded Metabase + MinusX application:
Run:
npm installCreate a .env file in the root directory with the following variables:
# Metabase Configuration
METABASE_JWT_SHARED_SECRET=your_jwt_shared_secret_here
# MinusX Configuration
MX_JWT_SHARED_SECRET=your_minusx_shared_secret_here
# A dashboard path which you wish to embed. Example: /dashboard/1-e-commerce-insights
METABASE_DASHBOARD_PATH=your_dashboard_path
# An editor path which you wish to embed. Can be sql or mbql Example: /question/139-demo-mbql/notebook
METABASE_EDITOR_PATH=your_editor_path #Example: /question/139-demo-mbql/notebook
# Proxy Configuration
TARGET=https://your-metabase-instance.com
EXTENSION_TARGET=https://web.minusxapi.com/extension-build
EMBED_HOST=http://localhost:9090Note: The MX_JWT_SHARED_SECRET is required for MinusX authentication. Contact us to discuss embedded plans and retrieve this shared JWT token.
Start the proxy server that handles:
- a. Injecting MinusX into Metabase
- b. Serving Custom CSS
- c. Setting cookie for MinusX on Metabase SSO auth
npm run proxyStart the main application server that:
- a. Sets
mx_jwtalong with Metabase JWT using a MinusX shared JWT - b. Handles authentication and UI for your application
npm run serverCustomize the appearance by modifying the custom.css file. This file contains styling for the MinusX integration and can be customized with your branding and theming preferences.
You can customize the appearance by modifying the custom.css file. This file is served when /minusx.css is requested, allowing you to:
- Override default styles
- Define custom CSS variables (like the minusxGreen color palette)
- Apply custom branding and theming
The current custom.css includes CSS variables for a custom color palette:
:root {
--chakra-colors-minusxGreen-50: #ebf8ff;
--chakra-colors-minusxGreen-100: #bee3f8;
/* ... more color variables ... */
}Start the proxy server in MX dev mode to run minusx locally. You'll need a minusx repo in the parent folder and running in dev mode for this to work.
npm run proxy-mxdevVisit http://localhost:9090
The application provides the following endpoints:
/analytics- Main dashboard view (embeds the configured dashboard path)/editor- Question builder interface (embeds the configured editor path)/question?hash=<hash>- Direct question viewer (loads/question#<hash>from Metabase without authentication)
Example: http://localhost:9090/question?hash=abc123 will load http://localhost:9091/question#abc123
This application consists of two main components that work together to provide MinusX integration with embedded Metabase:
The main application server serves as your primary application interface and handles:
- User Interface: Provides a custom dashboard UI with sidebar navigation for switching between Metabase dashboards and question builders
- Session Management: Manages user sessions with mock user data for development purposes
- Metabase SSO Authentication: Generates JWT tokens for Metabase authentication using the
METABASE_JWT_SHARED_SECRET - MinusX Authentication: Creates MinusX JWT tokens using the
MX_JWT_SHARED_SECRETfor user authentication with MinusX services - Dual JWT Handling: The
/sso/metabaseendpoint creates both Metabase and MinusX JWTs simultaneously, passing them to the proxy server for injection into Metabase
The proxy server acts as an intelligent middleware between your application and Metabase, handling:
- MinusX JavaScript Injection: Automatically injects the MinusX content script (
/contentScript.bundle.js) into all Metabase HTML pages, enabling the MinusX side panel functionality - Custom CSS Serving: Serves your custom CSS file at
/minusx.cssendpoint, allowing you to customize the MinusX interface appearance and branding - MinusX JWT Cookie Setting: Intercepts
/auth/ssorequests and sets themx_jwtcookie in the browser, which MinusX uses for user authentication - Asset Proxying: Routes MinusX extension assets (JS bundles, CSS, SVG files) either from the production CDN (
web.minusxapi.com) or from local filesystem in development mode - Content Security Policy (CSP) Modification: Dynamically updates Metabase's CSP headers to allow MinusX frame sources, ensuring the MinusX side panel can load properly
- Transparent Proxying: Forwards all other requests to your Metabase instance while intercepting and modifying responses as needed
- User accesses the main application (server.js)
- Application redirects to
/sso/metabasewith both Metabase and MinusX JWTs - Proxy server intercepts the SSO request and sets the MinusX JWT as a browser cookie
- Metabase authenticates the user and loads the embedded content
- Proxy server injects MinusX JavaScript into Metabase pages
- MinusX initializes using the JWT cookie for authentication, adding the side panel to Metabase

