This guide walks a Next.js 14+ App Router app from local code to a production URL with a database and per-user auth. Every step has runnable TypeScript code. By the end you have a working app atDocumentation Index
Fetch the complete documentation index at: https://getfloo.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
https://<app>.on.getfloo.com with a Postgres sibling service, signed-in users, and (optionally) your own domain.
If you’ve never deployed to floo before, read Golden Path first for the minimal three-command flow.
Before you start
You need:- A Next.js 14+ App Router project (or a fresh
npx create-next-app@latest). - The project pushed to a GitHub repository. floo pulls source from GitHub — it does not upload local files.
- The floo CLI installed and authenticated (
curl -fsSL https://getfloo.com/install.sh | bashthenfloo auth login).
1. Add a Dockerfile
Configure Next.js for standalone output (much smaller container):next.config.js
Dockerfile
2. Build-time env vars (NEXT_PUBLIC_*)
Any NEXT_PUBLIC_* variable referenced in your code is baked into the JS bundle at build time, not read at runtime. You must thread it through the Dockerfile as a build arg, and tell floo to pass it on every build.
Dockerfile
--build-arg:
undefined baked in.
3. Initialize the floo config
floo.app.toml
4. Connect the repo and deploy
Your Next.js app is live at
https://my-nextjs-app-dev.on.getfloo.com.Every git push origin main ships to dev. floo releases promote --app my-nextjs-app publishes to https://my-nextjs-app.on.getfloo.com.5. Add a Postgres database
DATABASE_URL is injected into the runtime. With Prisma:
prisma/schema.prisma
migrate_command = "npx prisma migrate deploy" runs after every deploy and promote, keeping schema in sync.
6. Add per-user auth
floo manages user authentication for you. Setaccess_mode = "accounts" in floo.app.toml:
floo.app.toml
- Redirects unauthenticated requests to a hosted login page.
- Validates the session cookie on every request.
- Injects identity headers into every request that reaches your Next.js app.
app/dashboard/page.tsx
curl -H 'X-Floo-User-Email: you@example.com' or wrap a helper that returns a fixture user when the headers are missing.
For the full reference on access modes and identity headers, see Add User Auth to Your App.
7. Add a custom domain
Host and X-Forwarded-Host from the request — no extra config needed.
8. Local development with prod data
dev_command locally with DATABASE_URL and other env vars sourced from your dev floo app — real Cloud SQL connection, no credentials in your shell history.
To also test signed-in flows for this accounts-mode app, add --fixture-user:
floo dev then starts a small proxy in front of each service that injects the same X-Floo-User-* headers floo’s gateway adds in production. The output table shows both the raw service URL and the auth-proxied URL — hit the auth-proxied one for any path that reads identity headers.
Common gotchas
/healthzis reserved. Cloud Run’s edge intercepts that exact path. Use/healthor/livez.HOSTNAME=0.0.0.0. Next.js standalone defaults tolocalhost, which Cloud Run won’t reach.NEXT_PUBLIC_*build args. Build-time vars must be threaded through the Dockerfile asARG/ENVand passed viafloo env set ... --build-arg. Otherwise the bundle hasundefinedbaked in.output: "standalone"innext.config.js. The Dockerfile above assumes standalone output. Without it, the build artifact is much larger and theCOPY --from=build /app/.next/standaloneline fails.
What’s next
Add User Auth — full reference
Identity headers, access policies, and access modes in detail.
Multi-Service Routing
Deploy Next.js alongside a FastAPI or Express backend with shared origin.
Environment Variables
Build-time vs runtime env vars, and the
--build-arg flag in detail.Custom Domains
DNS, verification, multi-service routing.