![]()
Metabase is a powerful open source tool for business intelligence and analytics. In this article we will integrate our Metabase dashboard into a Nuxt 3 application with Metabase embeds. Metabase embedding with a signed JWT keeps the dashboard private: only your server can produce a working embed URL, and it decides which rows each viewer sees.
Metabase vs Nuxt: which one do you need?
They aren't alternatives, so it's rarely one or the other. Metabase is an open source business intelligence tool: it connects to your database (PostgreSQL, MySQL and many others) and lets you build charts and dashboards without writing frontend code. It runs as its own Java server, from a JAR file or a Docker image. Nuxt is a framework for building web apps with Vue, with server rendering and server routes. It's where your product lives.
| Metabase | Nuxt | |
|---|---|---|
| What it is | BI and dashboard tool | Vue web app framework |
| You build | Questions, charts and dashboards, mostly in its UI | Pages, components and API routes, in code |
| Who uses it | Your team, or your users through an embed | Your users |
| Runs as | Its own server (JAR or Docker) | Your app's server, or static files |
Which one you reach for depends on who looks at the charts:
- Only your team needs the numbers: run Metabase on its own. You don't need Nuxt for that.
- Your users should see charts inside your app: keep both and embed Metabase in the Nuxt app. That's what the rest of this post does.
- The charts need to look and behave exactly like the rest of your UI: draw them yourself in Nuxt with a chart library on top of your own API, and skip Metabase.
What are the ways to embed a Metabase dashboard?
Metabase has changed its names for these since I first wrote this post, so here is how they map today, going by the Metabase embedding docs:
| Static embed (now "guest embed") | Full app embedding (was "interactive") | Public embed | |
|---|---|---|---|
| How it loads | iframe with a signed JWT in the URL. Guest embeds use a web component with the same token | The whole Metabase app in an iframe | iframe with a public link |
| Who can see it | Anyone your server signs a token for | People with a Metabase account, through SSO | Anyone with the link |
| Restricting rows | Locked parameters in the JWT | Metabase permissions | None |
| Drill-through, query builder | No, view only | Yes | No |
| Plan | Every plan, with a "Powered by Metabase" banner on Open Source and Starter | Pro and Enterprise | Every plan |
This post uses the static embed. Metabase now marks it deprecated in favor of guest embeds, but existing static embeds keep working, and both use the same secret key and token payload.
Full app embedding is for when your users need to explore data themselves, and every viewer needs a Metabase account through SSO. For an admin panel with fixed charts, the signed embed is enough.
Step 1: Create embedding on Metabase



After creating the embedding, Metabase gives you example code. Keep that code, we're going to use it on the Nitro server side.
An admin has to turn embedding on first. In current versions that's in the Embedding hub, under Security, next to the embedding secret key. Anyone with that key can open every embedded item, so keep it on the server.
While you're in the embed settings, decide what each dashboard filter should be:
- Disabled: no widget, and nobody can set a value.
- Editable: viewers see the widget and can change it.
- Locked: no widget, and your server sets the value in the token.
Then publish. If you change these settings later, publish again and update your server code to match.
Step 2: Integrating Metabase Embed to our Nuxt 3 project
First I'm going to create server/api/metabase/index.get.ts. This file provides the yourdomain.com/api/metabase endpoint.
But before we start, we need to install one dependency, which is jsonwebtoken:
npm i jsonwebtoken --save
After installation our code should look like this:

Now we need to integrate it on the client side:

I made an API call to the /api/metabase endpoint to get the iframe URL, and I also wrapped the iframe in ClientOnly tags.
Keep the secret key in runtimeConfig
The screenshot reads process.env directly. In Nuxt I'd rather put both values in runtimeConfig. Keys at the top level of runtimeConfig are only available on the server, and Nuxt fills them from environment variables that start with NUXT_:
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
metabaseSecretKey: "", // NUXT_METABASE_SECRET_KEY
metabaseSiteUrl: "", // NUXT_METABASE_SITE_URL
},
});
The same route as text, using that config:
// server/api/metabase/index.get.ts
import jwt from "jsonwebtoken";
export default defineEventHandler((event) => {
const config = useRuntimeConfig(event);
const payload = {
resource: { dashboard: 24 },
params: {},
exp: Math.round(Date.now() / 1000) + 10 * 60,
};
const token = jwt.sign(payload, config.metabaseSecretKey);
return `${config.metabaseSiteUrl}/embed/dashboard/${token}#bordered=true&titled=true`;
});
Never put the secret under runtimeConfig.public or sign the token in a component. Anything public ends up in the browser, and with the key a visitor could sign a token for any published dashboard.
One more thing the screenshot leaves out: an iframe without a height renders as a short strip. Give it a real height, for example class="w-full h-[800px]" with Tailwind.
How do you pass locked parameters in the JWT?
This is how you show each customer only their own data. Set the filter to Locked in the embed settings, then put its value in params:
// server/api/metabase/index.get.ts
import jwt from "jsonwebtoken";
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig(event);
const user = await getCurrentUser(event); // your own auth check
if (!user) {
throw createError({ statusCode: 401 });
}
const payload = {
resource: { dashboard: 24 },
params: { customer_id: [user.customerId] },
exp: Math.round(Date.now() / 1000) + 10 * 60,
};
const token = jwt.sign(payload, config.metabaseSecretKey);
return `${config.metabaseSiteUrl}/embed/dashboard/${token}#bordered=true&titled=true`;
});
getCurrentUser stands for whatever auth you already have. The value must come from your session on the server, never from a query string.
The rules from the Metabase parameters docs:
- The key is the filter's slug, not its label. Rename the filter and you have to update the key.
- Values are arrays, one element per value:
customer_id: [13]. - Every token has to include every locked parameter, or the cards show an error.
- An empty array
[]turns the filter off and shows every row. If you build the list per user, check it isn't empty before you sign. ""andnullcount as no value, so the token is rejected.- Always send
params, even as{}.
How long should the embed token last?
The exp claim is a Unix timestamp in seconds. The example code from Metabase sets 10 minutes, and that's what I use. Once a token expires, the embed can't load fresh data, and a token Metabase can't accept at all (expired, or signed with the wrong key) stops the whole embed from loading.
My page asks /api/metabase for a new URL on every load, so a short expiry costs nothing. For a page left open for hours, reload the iframe with a fresh URL or move to guest embeds.
How do you theme a static embed?
The appearance options go in the URL hash after the token. That's the #bordered=true&titled=true part of the route above. From Metabase's appearance parameters:
| Parameter | Values |
|---|---|
bordered | true (default), false |
titled | true (default), false |
theme | night for dark mode |
background | false for a transparent dashboard background |
refresh | Seconds between refreshes, dashboards only |
hide_parameters | Slugs of editable filters whose widgets you want hidden |
font, locale, downloads | Pro and Enterprise only |
Join several with &, like #bordered=false&titled=true. Hiding a widget only hides it. If the value has to be enforced, lock the parameter instead.
Moving to guest embeds
Metabase's migration notes say to keep your signing code as it is, because the payload with resource, params and exp doesn't change. You replace the iframe with their web component and pass the token as an attribute:
<script defer src="https://metabase.example.com/app/embed.js"></script>
<script>
window.metabaseConfig = {
isGuest: true,
instanceUrl: "https://metabase.example.com",
};
</script>
<metabase-dashboard token="YOUR_JWT" with-title="true"></metabase-dashboard>
In Nuxt, the route returns the token instead of a URL. Vue also needs to know that metabase-dashboard is a custom element, which you can tell it with vue.compilerOptions.isCustomElement in nuxt.config.ts. Guest embeds can also call an endpoint of yours through guestEmbedProviderUri to get a fresh token when the old one expires, which solves the long-open-page case.
Common Metabase embedding errors
These messages are from Metabase's docs, shown here for a filter with the slug customer_id:
| Message | Cause |
|---|---|
You must specify a value for :customer_id in the JWT. | The filter is locked and the token doesn't include it, or sends "" or null |
You're not allowed to specify a value for customer_id. | The filter is Disabled in the embed settings |
You can only specify a value for customer_id in the JWT. | The page tried to set a locked filter through the URL |
Unknown parameter customer_id. | The filter was added after you published. Publish again |
Token is missing value for keypath [:params] | The payload has no params. Send {} |
If the whole embed refuses to load, check the secret key first. Regenerating it in Metabase breaks every token signed with the old one. Then check that exp is in seconds, not milliseconds. If the key comes out empty on the server, the environment variable is probably missing its NUXT_ prefix. On Vercel, also remember that changed environment variables only apply after a redeploy, which I go into in deploying on Vercel.
The result
We've embedded a Metabase dashboard in a Nuxt 3 application, and now we can view it in our own custom dashboard.

For charts from Prometheus metrics instead of a database, see Grafana with Docker Compose, and for more Nuxt, Nuxt vs Next. If you want this built into your own panel, I'm available for freelance work.
FAQ
Is Metabase embedding free?
Guest embeds work on every plan, including the open source edition, with a "Powered by Metabase" banner on Open Source and Starter. Full app embedding and SSO embeds need Pro or Enterprise.
What is the difference between static and interactive embedding in Metabase?
A static embed shows a view-only dashboard that your server signs, with no Metabase account per viewer. Interactive embedding, now called full app embedding, loads the whole Metabase app with SSO, so viewers can drill through and build their own questions.
Can a viewer change a locked parameter?
No. Metabase only accepts a locked value from the signed token and rejects one that comes from the page. As long as the secret key stays on your server, viewers can't change it.
Why does my embedded dashboard stop working after a while?
The token has expired. Sign a new one on every page load, or use guest embeds with a token endpoint so the embed refreshes itself.