- The Node.js quickstart done, or at least a Courier API key and a user in Courier.
- An Astro app on Node 20.9 or newer with a server adapter, plus
@trycourier/courier. Add@astrojs/reactand@trycourier/courier-reactfor the inbox.
1. Declare the key as a server secret
Read the key throughastro:env, not import.meta.env. access: "secret" reads the environment on every request; import.meta.env.COURIER_API_KEY compiles to the build-time value as a string literal and bakes the key into the bundle you deploy. Do not prefix it with PUBLIC_, which Astro inlines into the browser build.
2. Send from an endpoint
Endpoints run on the server, so this is where a Courier call belongs. Setprerender = false so the route runs per request instead of being built once. The template lives in Design Studio, so copy and channel routing change without a deploy.
3. Add the inbox: token endpoint plus island
The inbox runs in the browser, so it gets a JWT scoped to one user and expiring, signed by your key on the server. The repo mints it insrc/pages/api/courier/token.ts and reads the user id from the session, never from the request, because a caller who can name any user can read that userβs inbox.
client:only="react". The inbox renders as a custom element, so a server pass would render nothing and then throw it away.
Next steps
- Astro quickstart repo: clone it, add a key, run
npm run devandnpm run send. - Node.js quickstart: users, routing, journeys, delivery status.
- In-app inbox: scopes, tenants, and the rest of the inbox.
- Node.js SDK reference.
- React SDK reference.