Deploy Next.js Better Auth Prisma SaaS Starter Kit
Next.js starter with Better Auth, Prisma/Postgres and role-based dashboards
Just deployed
Just deployed
/var/lib/postgresql/data
Deploy and Host Next.js Better Auth Prisma SaaS Starter Kit on Railway
Next.js Better Auth Prisma SaaS Starter Kit is an open-source, production-ready starter for building SaaS products with Next.js 16, Better Auth, Prisma and PostgreSQL. It includes email and password login, Google OAuth, email verification, password reset, role-based access, admin and user dashboard layouts, and a shadcn/ui interface.
About Hosting Next.js Better Auth Prisma SaaS Starter Kit
Deploying the template on Railway creates two services: the Next.js app and a PostgreSQL database. Railway builds the app, generates the Prisma client and wires DATABASE_URL automatically. On every start the app applies pending database migrations, so the schema stays up to date. A built-in /api/health endpoint checks the database and serves as Railway's healthcheck, with automatic restarts on failure. You get a public HTTPS URL as soon as the first deploy finishes. After that, make sure your auth secret and public URL are set, add your Resend and Google credentials, then push to your repository to redeploy.
Common Use Cases
- SaaS MVPs and client projects - Start from a typed, consistent base with authentication and role-based access already working, plus admin and user dashboard layouts to build on, and spend your time on the features that make each product unique.
- Admin panels and internal tools - Protect pages with sessions and an
adminrole so only authorized users can access them. - Membership and gated-content portals - Offer sign-up with email verification, Google login and password recovery out of the box.
Dependencies for Next.js Better Auth Prisma SaaS Starter Kit Hosting
- PostgreSQL - Provisioned automatically by Railway. It stores users, sessions, accounts and verification tokens.
- Resend - Sends the verification and password reset emails. Email verification is required to sign in with email and password, so a
RESEND_API_KEYand a sender address on a domain you have verified in Resend are needed. - Google OAuth credentials - Needed to enable the "Sign in with Google" login.
Implementation Details
After deploying, check that these variables are set on the Next.js service and add any that are empty:
# Provided by the Railway PostgreSQL service
DATABASE_URL=postgresql://...
# Generate with: openssl rand -base64 32
BETTER_AUTH_SECRET=your_secret_here
# Your public URL. Also used for password reset links, the social preview image,
# sitemap and robots.txt. It is read at build time, so redeploy after changing it
BETTER_AUTH_URL=https://your-app.up.railway.app
NEXT_PUBLIC_BASE_URL=https://your-app.up.railway.app
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Transactional email via Resend
RESEND_API_KEY=re_your_api_key
EMAIL_SENDER_NAME=Your App
EMAIL_SENDER_ADDRESS=noreply@yourdomain.com
In Google Cloud Console, add https://your-app.up.railway.app/api/auth/callback/google as an authorized redirect URI.
The first admin: sign up normally, then set that user's role to admin in the database (the Postgres service's Data tab in Railway works, or bunx prisma studio with the database's public connection URL). Signing in with email and password takes that user to /admin; with Google sign-in they land on /dashboard and can open /admin directly.
To customize, edit the site name and metadata in src/lib/constants.ts and src/app/layout.tsx, and add or change login providers in src/lib/auth.ts. Source code: GitHub repository.
Why Deploy Next.js Better Auth Prisma SaaS Starter Kit on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Next.js Better Auth Prisma SaaS Starter Kit on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content