# How to Deploy a T3 Stack App to Production With AI in 2026?

> How to deploy a T3 Stack app in 2026. Step-by-step guide for Next.js, tRPC, Prisma migrations, NextAuth, and one-click deployment on Kuberns without Docker.
- **Author**: omkar-anbhule
- **Published**: 2026-05-02
- **Modified**: 2026-07-10
- **Category**: Deployment Guides
- **URL**: https://kuberns.com/blogs/deploy-t3-stack-app/

---

Deploying a T3 Stack app to production means running a full-stack TypeScript application, not a static site. The T3 Stack (Next.js, tRPC, Prisma, Tailwind CSS, and NextAuth.js scaffolded with [`create-t3-app`](https://create.t3.gg/)) ships with a persistent server, a database, OAuth callbacks, and environment variables that must all be wired together correctly before a single user can sign in. That is why serverless platforms with function timeouts and sleep behavior are not the right fit for it.

Kuberns solves this by running your T3 app as a persistent Node.js server with no function timeouts. Connect your GitHub repo, add your environment variables, and Kuberns builds your app, runs Prisma migrations, and gives you a live HTTPS URL in under 10 minutes. This guide covers every configuration step for Prisma, NextAuth, and tRPC to work correctly in production.

## TL;DR

* The T3 Stack (Next.js, tRPC, Prisma, NextAuth) needs a persistent Node.js server, not a serverless platform with function timeouts.
* Key pre-deploy steps: set `SKIP_ENV_VALIDATION=1`, add `prisma generate` to `postinstall`, and configure `NEXTAUTH_URL` and `NEXTAUTH_SECRET`.
* On Kuberns, connect your GitHub repo, add env vars, and click Deploy. The agentic AI handles build, Prisma generation, SSL, CI/CD, and auto-scaling automatically.
* No Dockerfile, no YAML, no SSH required.

## Prerequisites: Prepare Your T3 App for Production

These steps take less than ten minutes and prevent the most common T3 deployment failures.

### 1. Confirm Your package.json Scripts

Kuberns AI reads your `scripts` block to determine the build and start commands. A standard T3 app from `create-t3-app` already has the right scripts, but verify they look like this:

```json
{
  "scripts": {
    "build": "next build",
    "start": "next start",
    "dev": "next dev",
    "db:push": "prisma db push",
    "db:migrate": "prisma migrate deploy",
    "postinstall": "prisma generate"
  },
  "engines": {
    "node": ">=20.0.0"
  }
}
```

The `postinstall` script runs `prisma generate` automatically after `npm install`, which means Prisma Client is always generated before your app starts. This is critical: without it, your tRPC procedures that call Prisma will fail with a "PrismaClient is not generated" error.

### 2. Set NODE_ENV to Skip Environment Validation During Build

The T3 Stack uses `@t3-oss/env-nextjs` for type-safe environment variable validation. By default, this runs at build time and will throw if any required variables are missing.

Since environment variables are injected by Kuberns at runtime (not embedded in the build), you need to skip validation during the build step. Open your `env.js` file and check the `skipValidation` option:

```js
export const env = createEnv({
  // ...
  skipValidation: !!process.env.SKIP_ENV_VALIDATION,
  // ...
});
```

Then add `SKIP_ENV_VALIDATION=1` as an environment variable in the Kuberns dashboard. This tells `@t3-oss/env-nextjs` to skip validation at build time while still validating at runtime when your server starts.

### 3. Configure Prisma for Production

Make sure your `schema.prisma` uses an environment variable for the database URL and sets the correct provider:

```prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
```

For managed databases like Supabase, PlanetScale, or Neon that require SSL, add the connection pool URL as your `DATABASE_URL` and the direct URL as `DIRECT_URL`:

```prisma
datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}
```

Use the direct URL for migrations and the pooled URL for runtime queries.

### 4. Set NEXTAUTH_URL to Your Production Domain

[NextAuth.js requires](https://next-auth.js.org/configuration/options#nextauth_url) `NEXTAUTH_URL` to be set to the exact URL of your production app, including the protocol. When you deploy to Kuberns, you will get a live HTTPS URL. Add it as `NEXTAUTH_URL` in the Kuberns environment tab before the first deploy.

For OAuth providers, you also need to update your callback URLs in the provider dashboard (Google Cloud Console, Discord Developer Portal, GitHub OAuth Apps, etc.) to include your Kuberns deployment URL.

### 5. Push Your Code to GitHub

Kuberns deploys directly from your repository:

```bash
git add .
git commit -m "Prepare T3 app for production"
git push origin main
```

That is the complete prerequisite list. No Dockerfile, no YAML config, no CLI tools to install.

> Serverless platforms impose function execution timeouts on API routes. Any tRPC mutation or query that takes longer than the limit, such as sending emails, processing uploads, or calling an AI API, will fail with a 504 error in production. On [Kuberns](https://kuberns.com/), your T3 app runs as a persistent Node.js server with no function timeouts. Your tRPC procedures run as long as they need to.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/CTA_banner.png" alt="Deploy your T3 Stack app on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## How to Deploy a T3 Stack App on Kuberns (Step by Step)

[Kuberns](https://kuberns.com/) is an agentic AI deployment platform built on AWS. It auto-detects Next.js from your `package.json`, installs dependencies (including running `prisma generate` via your `postinstall` script), runs `next build`, starts your app with `next start`, provisions SSL, and manages auto-scaling without any configuration from you. For teams deploying other AI-powered apps, see our [AI-based software development guide](https://kuberns.com/blogs/ai-based-software-development/).

### Step 1: Create Your Kuberns Account

![Kuberns homepage](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-homepage.png)

Go to [kuberns.com](https://kuberns.com/) and click **Deploy for Free**. Create your account and verify your phone number.

New accounts get free credits to deploy without a credit card. [See all pricing tiers here](https://kuberns.com/pricing/).

### Step 2: Connect Your GitHub Repository

![Connect GitHub to Kuberns](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-registration.png)

On the **Creating a Service** page, connect your GitHub account and select the repository that contains your T3 app.

- Click **Connect and Configure** and authorize Kuberns access to your repositories
- Select your repository and the branch you want to deploy (typically `main`)

Kuberns AI scans your project, detects Next.js from your `package.json`, and identifies the build and start scripts automatically.

> **You do not specify a build command, a start command, a Node version, or any runtime configuration.** The agentic AI reads your repository and configures the full deployment pipeline without any input from you.

### Step 3: Add Environment Variables

![Environment variables on Kuberns](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/environment-variable-kuberns.png)

Before clicking Deploy, navigate to the **Environment** section and add your app secrets.

Click **Add Env Vars** to add key-value pairs manually, or click **Upload .env file** to import all variables at once from your local `.env`.

For a standard T3 app, add these variables:

| Variable | Description |
|---|---|
| `DATABASE_URL` | Your PostgreSQL connection string (pooled URL for Supabase/Neon) |
| `DIRECT_URL` | Direct connection URL (only needed for Supabase/Neon with Prisma) |
| `NEXTAUTH_SECRET` | A long random string for signing sessions (generate with `openssl rand -base64 32`) |
| `NEXTAUTH_URL` | Your production HTTPS URL (you will get this after the first deploy) |
| `SKIP_ENV_VALIDATION` | Set to `1` to skip build-time env validation |
| `NODE_ENV` | Set to `production` |

For OAuth providers, also add:

| Variable | Description |
|---|---|
| `DISCORD_CLIENT_ID` | Your Discord OAuth app client ID |
| `DISCORD_CLIENT_SECRET` | Your Discord OAuth app client secret |
| `GOOGLE_CLIENT_ID` | Your Google OAuth client ID |
| `GOOGLE_CLIENT_SECRET` | Your Google OAuth client secret |

Kuberns encrypts all values at rest. They never appear in build logs or deployment output.

### Step 4: Click Deploy

![Kuberns AI deploying app](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-ai-deploying.png)

Click **Deploy**. Kuberns agentic AI takes over:

- Clones your repository from GitHub
- Runs `npm install` which also triggers `prisma generate` via your `postinstall` script
- Runs `next build` to compile your T3 app
- Starts your app with `next start` as a persistent Node.js process
- Provisions AWS compute in your chosen region
- Issues an SSL certificate and assigns a live HTTPS URL
- Enables monitoring, logging, and AI-driven auto-scaling
- Sets up CI/CD so every future push to the connected branch triggers an automatic redeploy

### Step 5: Your T3 App is Live

![Kuberns deployment dashboard](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/deployed-dashboard.png)

Your T3 app is live with a verified HTTPS URL in under five minutes. From the Kuberns dashboard you can:

- Open your deployed URL and test authentication, tRPC queries, and database calls
- View live usage stats and resource consumption
- Check real-time build logs and deployment history
- Update environment variables without redeploying
- Monitor AI-driven auto-scaling metrics

Once you have your Kuberns URL, go back and set `NEXTAUTH_URL` to that URL in your environment variables, and update the OAuth callback URLs in your provider dashboards.

## Running Prisma Migrations on Deploy

Prisma migrations in production should use `prisma migrate deploy`, not `prisma db push`. The `db push` command is for development only and can cause data loss on a production database.

The cleanest way to run migrations automatically on every deploy is to add them to your start script in `package.json`:

```json
{
  "scripts": {
    "start": "prisma migrate deploy && next start"
  }
}
```

This runs any pending migrations before Next.js starts accepting traffic on each deploy. If a migration fails, the app does not start and the previous version stays live.

For more complex migration strategies (blue-green deployments, rollback plans), you can also run migrations manually from your local machine against the production `DATABASE_URL` before pushing a new deploy.

## Connecting a Database to Your T3 App

The T3 Stack uses Prisma, which works with any PostgreSQL-compatible database. Here are the options that pair well with Kuberns:

| Database | Best for | Connection string format |
|---|---|---|
| **Supabase** | Teams who want a managed Postgres with a dashboard and auth | `postgresql://postgres:[password]@db.[project].supabase.co:5432/postgres` |
| **Neon** | Serverless Postgres with fast cold starts and branching | `postgresql://[user]:[password]@[endpoint].neon.tech/[db]?sslmode=require` |
| **PlanetScale** | MySQL-compatible serverless DB (note: no foreign keys) | `mysql://[user]:[password]@[host]/[db]?sslaccept=strict` |
| **Railway Postgres** | Simple managed Postgres, easy to spin up | `postgresql://[user]:[pass]@[host]:[port]/[db]` |
| **AWS RDS** | Production-grade Postgres on the same AWS infrastructure as Kuberns | Standard PostgreSQL connection string |

For Supabase and Neon, use the connection pooler URL as `DATABASE_URL` and the direct URL as `DIRECT_URL` in your Prisma schema. This prevents connection exhaustion from Prisma creating too many direct connections.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner6.png" alt="Deploy your T3 Stack app on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## Configuring NextAuth.js for Production

NextAuth.js requires three things to work correctly in production:

### 1. NEXTAUTH_SECRET
Generate a secure random secret and add it to Kuberns:

```bash
openssl rand -base64 32
```

Without this, NextAuth throws a `[next-auth][error][NO_SECRET]` error and authentication breaks entirely.

### 2. NEXTAUTH_URL
Set this to your exact production URL including the protocol:

```
NEXTAUTH_URL=https://your-app.kuberns.app
```

Or your custom domain if you have one configured in Kuberns:

```
NEXTAUTH_URL=https://yourdomain.com
```

### 3. OAuth Provider Callback URLs
For every OAuth provider you use, add the callback URL to that provider's dashboard. The format is:

```
https://your-production-url/api/auth/callback/[provider]
```

For example:
- Discord: `https://your-app.kuberns.app/api/auth/callback/discord`
- Google: `https://your-app.kuberns.app/api/auth/callback/google`
- GitHub: `https://your-app.kuberns.app/api/auth/callback/github`

If these are not updated, OAuth sign-in will redirect back to localhost or fail with a redirect URI mismatch error.

## What Kuberns Handles That You Do Manually on Other Platforms

| What a T3 app needs in production | Manual / VPS | Kuberns |
|---|---|---|
| Next.js build step | Configure CI manually | AI detects and runs automatically |
| Prisma Client generation | Add postinstall script | Runs automatically via npm install |
| Process manager | PM2 or systemd setup | Not needed, AI manages processes |
| Reverse proxy (Nginx) | Manual config | Not required |
| SSL certificate | Certbot setup and renewal | Automatic |
| Environment variable injection | Server env files | Encrypted in dashboard |
| Auto-scaling | Manual rules | AI-driven |
| CI/CD pipeline | GitHub Actions YAML | Built-in, triggers on Git push |
| Custom domain + HTTPS | DNS + Certbot | One-click in dashboard |
| Database migration on deploy | Run manually on server | Automate via start script |

## Conclusion

Deploying a T3 Stack app in 2026 does not have to involve Dockerfiles, Nginx configs, PM2 process managers, or manual SSL setup. The T3 Stack gives you a production-ready TypeScript full-stack foundation: Next.js, tRPC, Prisma, and NextAuth. Kuberns handles everything that comes after the code is written.

The key things to get right before deploying: add `SKIP_ENV_VALIDATION=1` to skip build-time env checks, ensure `prisma generate` runs via `postinstall`, set `NEXTAUTH_URL` and `NEXTAUTH_SECRET`, and chain `prisma migrate deploy` into your start script. Once those are in place, connect your GitHub repository on Kuberns, add your environment variables, and click Deploy. The agentic AI handles the rest: build, SSL, CI/CD, scaling, and monitoring, with no further configuration required.

[Deploy with Agentic AI on Kuberns](https://dashboard.kuberns.com)

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner9.png" alt="Start deploying on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## Frequently Asked Questions on T3 Stack Deployment

### Do I need a Dockerfile to deploy a T3 app on Kuberns?
No. Kuberns detects Next.js automatically from your `package.json` and handles the runtime environment internally. You push code from GitHub and the app deploys. No Dockerfile, no YAML, no configuration files.

### Why does my T3 app build fail with an environment variable error?
The T3 Stack validates environment variables at build time using [`@t3-oss/env-nextjs`](https://env.t3.gg/docs/introduction). Since Kuberns injects variables at runtime rather than embedding them in the build, you need to add `SKIP_ENV_VALIDATION=1` as an environment variable in the Kuberns dashboard. This skips build-time validation while still enforcing types at runtime. If your `env.js` extends the Vercel preset from `@t3-oss/env-core/presets-zod`, that preset is Vercel-specific and unnecessary on Kuberns. It can stay in your code without effect, but it does not replace `SKIP_ENV_VALIDATION`.

### How do I update my NEXTAUTH_URL after the first deploy?
After your first deploy, Kuberns assigns a live HTTPS URL to your app. Go to the Kuberns dashboard, copy the URL, then navigate to the Environment tab and add `NEXTAUTH_URL` with that value. Trigger a redeploy for the change to take effect. If you set up a custom domain later, update `NEXTAUTH_URL` again to match.

### Can I use tRPC subscriptions on Kuberns?
Yes. Kuberns runs your T3 app as a persistent Node.js server which supports WebSocket connections. tRPC subscriptions over WebSockets work without any extra configuration.

### How do I add a custom domain to my T3 app on Kuberns?
In the Kuberns dashboard, go to Domains, add your domain, and update your DNS A record to point to the Kuberns IP. Kuberns issues and renews the SSL certificate automatically. After adding your domain, update `NEXTAUTH_URL` to your custom domain and update the callback URLs in your OAuth provider dashboards.

### Is Kuberns better than Vercel for T3 apps?
For most T3 apps, yes. Vercel works well for T3 but the free plan has a 10-second API route timeout that affects tRPC mutations doing real work. Paid plans go up to 60 seconds but cost more as traffic grows. Kuberns runs your T3 app as a persistent server with no function timeouts, no cold starts on SSR pages, and predictable pricing from $7 per month. See the [Vercel vs Kuberns comparison](https://kuberns.com/blogs/vercel-vs-aws-vs-kuberns-choosing-the-right-cloud-platform-in-2026/) for a detailed breakdown.

### What database should I use with a T3 app on Kuberns?
Supabase and Neon are the two most popular choices. Both offer managed PostgreSQL with a generous free tier, Prisma-compatible connection strings, and SSL. Use the connection pooler URL as `DATABASE_URL` and the direct URL as `DIRECT_URL` in your Prisma schema to avoid connection exhaustion in production.

### Does create-t3-app use a src directory by default?

No. By default, `create-t3-app` places your source files in the root directory: `pages/` or `app/` for Next.js routes, `server/` for tRPC routers and Prisma, and `styles/` for CSS. The CLI offers an optional `src` directory layout when you run it interactively. If you answer yes to the src directory prompt, all source files move into `src/`. Most T3 projects and community examples use the root layout without `src/`.

### What does SKIP_ENV_VALIDATION do in a T3 app?

`SKIP_ENV_VALIDATION=1` tells the `@t3-oss/env-nextjs` package to skip type-safe environment variable validation at build time. This is necessary when deploying to platforms like Kuberns where environment variables are injected at runtime rather than embedded in the build. Without this flag, `next build` will throw an error if any required env vars are missing. Runtime validation still runs when your server starts, so type safety is preserved in production.

### What is the latest create-t3-app CLI command in 2026?

The latest command to scaffold a T3 app in 2026 is: `npm create t3-app@latest my-app`. This runs the interactive CLI which lets you choose TypeScript, tRPC, Tailwind CSS, Prisma or Drizzle ORM, NextAuth.js or Clerk, and whether to use the App Router. You can also pass flags for non-interactive use: `npm create t3-app@latest my-app --CI --trpc --tailwind --prisma --nextAuth

---
- [More Deployment Guides articles](https://kuberns.com/blogs/category/deployment-guides/1/)
- [All articles](https://kuberns.com/blogs/)