Configuring NEXT_PUBLIC_APP_URL
Configuring NEXT_PUBLIC_APP_URL
NEXT_PUBLIC_APP_URL is a required environment variable that tells the platform what its own publicly accessible base URL is. Several core features depend on it.
Why It Is Required
The platform constructs absolute URLs at runtime for:
- User invite links — When a user is invited to a workspace, an email is sent containing an accept link in the form
<NEXT_PUBLIC_APP_URL>/invite/<TOKEN>. If the variable is missing, the link renders asundefined/invite/<TOKEN>, which is unreachable. - Stripe billing redirects — After a Stripe checkout session completes or is cancelled, Stripe redirects the user back to your application using URLs derived from this variable. An unset value results in a malformed redirect URL and a broken billing flow.
Setting the Variable
Add the following to your deployment environment (e.g. .env.production, Vercel project settings, AWS SSM, or your CI/CD secrets store):
NEXT_PUBLIC_APP_URL=https://your-domain.com
Note: Do not include a trailing slash.
Local Development
For local development, add the variable to your .env.local file:
NEXT_PUBLIC_APP_URL=http://localhost:3000
Startup Assertion (Recommended)
To catch a missing value at boot time rather than at the point of failure, add the following assertion to your application entry point or server initialisation code:
if (!process.env.NEXT_PUBLIC_APP_URL) {
throw new Error(
'NEXT_PUBLIC_APP_URL is required. Set it to the public base URL of this deployment (e.g. https://your-domain.com).'
);
}
This ensures a misconfigured deployment fails loudly on startup rather than sending broken invite emails or silently dropping Stripe callbacks.
Affected Areas
| Feature | File | Behaviour without the variable |
|---|---|---|
| User invite emails | src/emails/templates.ts | Accept link is undefined/invite/<TOKEN> — unclickable |
| Invite email dispatch | src/inngest/functions/invite-email.ts | Email is sent but link is broken |
| Stripe billing redirects | src/lib/routers/billing.ts | Checkout success/cancel redirects fail silently |
Summary
| Variable | Required | Example value |
|---|---|---|
NEXT_PUBLIC_APP_URL | ✅ Yes | https://app.yourcompany.com |