Deploy Nextjs-Multitenant-Template

Multi-tenant SaaS starter for Next.js with Better Auth, Prisma and RBAC.

Deploy Nextjs-Multitenant-Template

/var/lib/postgresql/data

Frontend-Multitenancy

laguillo/nextjs-multitenant

Just deployed

Deploy and Host Nextjs-Multitenant-Template on Railway

Nextjs-Multitenant-Template is a production-ready multi-tenant SaaS starter built with Next.js. It ships with Better Auth for sign-in, Prisma with PostgreSQL for data, and shadcn/ui for the interface. Each organization gets its own space at /tenant/[slug] or its own subdomain, with role-based access (owner and member) and email invitations already in place.

About Hosting Nextjs-Multitenant-Template

This template deploys the Next.js app and a PostgreSQL database as two services in one Railway project. The app connects to the database over Railway's private network, and DATABASE_URL is wired to the bundled Postgres service automatically. After the first deploy, run bunx prisma migrate deploy once to create the schema. Then add the environment variables that Railway asks for: RESEND_API_KEY for transactional email, and optionally GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET for Google sign-in. BETTER_AUTH_SECRET is generated for you. The app uses your Railway public domain by default, so you can deploy without a custom domain. Add a custom domain later if you want tenant subdomains such as acme.yourdomain.com.

Common Use Cases

  • B2B SaaS products where each customer company needs its own workspace, members, and roles
  • Internal tools for teams or agencies that manage several client organizations from one app
  • Starting point for a multi-tenant app that needs authentication, invitations, and an admin area from day one

Dependencies for Nextjs-Multitenant-Template Hosting

  • PostgreSQL (provisioned automatically by the template)
  • A Resend account with a verified sending domain, for transactional emails
  • Optional: a Google OAuth client, for "Sign in with Google"

Implementation Details

The app has two routing modes. Platform routes (landing, sign-up, dashboard, and admin) live at the root domain. Tenant routes live under /tenant/[slug] and, when a custom domain is configured, under subdomains. Authentication is handled by Better Auth at src/lib/auth.ts, and organization membership and roles are enforced in the tenant layout. The database schema covers users, sessions, accounts, organizations, members, and invitations.

Why Deploy Nextjs-Multitenant-Template 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 Nextjs-Multitenant-Template 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

More templates in this category

View Template
Openfront Gym
Opensource Mindbody alternative based on Next.js and Keystone.js

Openship
0
View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
5
View Template
Next.js + Prisma + PostgreSQL Starter
Deploy a Next.js app with Prisma ORM and PostgreSQL in one click.

blueorange
0