All Docs
Getting StartedAgentOS WorkUpdated March 11, 2026

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 as undefined/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

FeatureFileBehaviour without the variable
User invite emailssrc/emails/templates.tsAccept link is undefined/invite/<TOKEN> — unclickable
Invite email dispatchsrc/inngest/functions/invite-email.tsEmail is sent but link is broken
Stripe billing redirectssrc/lib/routers/billing.tsCheckout success/cancel redirects fail silently

Summary

VariableRequiredExample value
NEXT_PUBLIC_APP_URL✅ Yeshttps://app.yourcompany.com