<CourierInbox> and one server route that mints its token. Courier hosts the feed, so you run no database or websocket server for it.
first-send.mts and run it with your key:
courier-nuxt-quickstart
The finished Nuxt app from this guide, ready to clone and run.
Build this with a coding agent
Paste this prompt into Claude Code, Cursor, or Codex from your Nuxt project root to have a coding agent add a Courier inbox:npx skills add trycourier/courier-skills, and connect the Courier MCP server so the agent can check Logs itself.
Rules for AI agents
- Use
@trycourier/courierandCOURIER_API_KEYonly inserver/andscripts/. The browser gets@trycourier/courier-vueand a scoped JWT. - Take the token’s user id from the session, never from the request.
- Scope each token
user_id:${userId} inbox:read:messages inbox:write:events, and always setexpires_in. - Call
courier.shared.signIn({ userId, jwt: token })inonMounted, with no<ClientOnly>wrapper. - Send with
routing: { method: "single", channels: ["inbox"] }to the token’suser_id.
What you’ll build
This Nuxt 4 app shows one user’s Courier Inbox and fills it from a script:- A Nuxt server route,
GET /api/courier-token, that mints a JWT scoped to one user - A live
<CourierInbox>from@trycourier/courier-vue - A send script that fills that user’s inbox
@trycourier/courier-vue 1.1.5, @trycourier/courier 10.2.0, and Node.js 22.18.
Prerequisites
For the first send
- A Courier account
- A Courier API key
- Node.js 22.18 or newer
For the full build
- A Nuxt 4 app, or a new one from the first step below
- A signed-in user from your session, such as nuxt-auth-utils
Clone the finished Nuxt app
Clone the Courier Nuxt quickstart and run it with your own key:Install the Courier packages in your Nuxt app
To add Courier to a new Nuxt app, scaffold one first and pin Nuxt 4.4:nuxi need Node 22.21, so the nuxi@3 scaffold and these pins keep the app on Node 22.18. Drop them on a newer Node.
Then add Courier’s Vue package for the browser and its Node package for the server:
tsx runs the send script, and the other dev packages run nuxt typecheck.
Put your key in .env, which nuxt dev loads:
.env
Mint the inbox token in a Nuxt server route
The Nuxt server route calls Courier’sPOST /auth/issue-token and returns a JWT scoped to one user.
server/api/courier-token.get.ts
inbox: scopes run the feed, and Scopes lists what preferences add.
Nitro reads process.env per request, so the key stays out of the build output. The demo user id lives in shared/demo-user.ts, which the send script shares:
Render the Vue notification inbox in Nuxt
The Nuxt component fetches the token, signs in with@trycourier/courier-vue, and renders <CourierInbox>.
app/components/NotificationInbox.vue
<ClientOnly>. The server renders an empty <courier-inbox> tag, and the browser turns it into the live feed on hydration.
Nuxt auto-imports components, so app/app.vue uses it by name:
app/app.vue
app/app.vue
app/app.vue
Send a test message to the Nuxt inbox
scripts/send.ts sends one Courier message to the Nuxt demo user’s inbox to prove the round trip. Add an npm run send script that loads .env:
scripts/send.ts
content.
Verify
Load the Nuxt inbox, send one Courier message, and watch it arrive. In the cloned repo, runnpm run dev and open localhost:3000, where the inbox renders signed in and empty. Then run npm run send in another terminal to print a request id. The message appears without a refresh, and the unread count moves.
In your own app, first set DEMO_USER_ID to your signed-in user, then load the page and run npm run send. Look up the request id in Courier Logs to follow the send to the inbox.
Go to production with Courier
Courier is notification infrastructure for humans and AI agents. Go live covers moving your Nuxt app from Test to Production:- Set the key on your host. Set
COURIER_API_KEYthere, because the built.output/server/index.mjsdoesn’t read.env. - Refresh tokens. Match
expires_into your session, then mint a new token and sign in again before it expires. - Make retries safe. Pass an idempotency key on sends that can retry, and retry with it safely.
FAQ
Can I use this in a plain Vue app without Nuxt?
Can I use this in a plain Vue app without Nuxt?
A plain Vue app uses the same
@trycourier/courier-vue component and signIn call, with the token route on your existing backend. See Add an inbox.How do I add a notification bell to a Vue app?
How do I add a notification bell to a Vue app?
A Courier notification bell in Vue is
<CourierInboxPopupMenu /> from @trycourier/courier-vue, the same feed behind an icon with an unread badge. See Render as a popup menu.Is the JWT safe to expose to the browser?
Is the JWT safe to expose to the browser?
A Courier inbox JWT is built for the browser, because it’s scoped to one user and expires. The API key that signs it stays on the server.
Why is the inbox empty when the send reported success?
Why is the inbox empty when the send reported success?
A Courier inbox feed is filtered by tenant, so signing in with a
tenantId hides messages sent without one. See Scope the inbox to a tenant.