Deploy Next + Prisma + tRPC | Typed Full-Stack on Current Versions

Next 16, Prisma 7, tRPC 11. Migrations run before the new version.

Deploy Next + Prisma + tRPC | Typed Full-Stack on Current Versions

/var/lib/postgresql/data

Deploy and Host Next + Prisma + tRPC on Railway

A typed full-stack app on Next 16, React 19, Prisma 7 and tRPC 11, with Postgres.

A working app, not a skeleton. Open the domain, write a post, and it goes through a typed tRPC call to Prisma to Postgres and comes back from the database.

About Hosting Next + Prisma + tRPC

The existing Next Prisma tRPC template deploys a repository last touched in May 2023: Next 13, Prisma 4.7, tRPC 10, React 18. No deployment of it succeeds; the template reports 0% health. Three years of unattended dependency drift will do that, and the stack has moved twice since: Prisma 7 changed where the connection string lives, and tRPC 11 changed where the transformer is configured.

Hosting this stack on a platform has one well-known trap: running migrations at build time. The build container has no database, and putting prisma migrate deploy in the build is the single most common way this stack fails on a platform. Here migrations run in the pre-deploy step, before the new version takes traffic.

Common Use Cases

  • A starting point for a typed full-stack app, with a working path from a tRPC call through Prisma to Postgres already in place.
  • Moving an older Next, Prisma or tRPC project to current versions, with a working reference for the Prisma 7 and tRPC 11 changes.

Dependencies for Next + Prisma + tRPC Hosting

Deployment Dependencies

DATABASE_URL is wired to the Postgres service over the private network, and the database password is generated. Nothing to fill in.

Implementation Details

  • Migrations run pre-deploy, not at build. prisma migrate deploy runs in the pre-deploy step, before the new version takes traffic.
  • prisma generate does run at build, because generated client code has to be in the image. Build and pre-deploy are different containers, and files written in the second one do not survive.
  • The health check asks the database. A process that is up but cannot reach Postgres is not serving anything; reporting it healthy only delays finding out.
  • The Node version is declared. Without it the builder picks its own default, Node 18 at the time of writing, and the install fails outright, because Prisma 7 requires 20.19 or newer.
  • The lockfile is committed and audits clean. Railway refuses to build when the lockfile carries a HIGH advisory, and three transitive dependencies here ship one; the overrides block pins the patched versions.

Prisma 7, If You Last Used 6

url is gone from the datasource block. The CLI reads it from prisma.config.ts; the application passes its own connection to PrismaClient through a driver adapter, @prisma/adapter-pg here. The upside on a platform is real: the schema no longer needs a reachable database at build time.

TypeScript 7

Next's built-in type checking uses a compiler API that TypeScript 7 does not expose, so experimental.useTypeScriptCli is on and Next runs tsc instead. That is what keeps this on the current TypeScript rather than pinning back to 6.

Why Deploy Next + Prisma + tRPC 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 + Prisma + tRPC 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
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
3
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5
View Template
Appsmith
Low-code platform for internal tools, dashboards, and admin panels.

Agaz Self-Host
1