Repository navigation
Description
Description
When deploying a Hono server generated by create-better-t-stack (with Turborepo + Prisma + Better-Auth + tRPC) to Vercel, the deployment fails with multiple issues that require significant manual workarounds.
Stack Configuration
- Frontend: Next.js
- Backend: Hono
- Monorepo: Turborepo
- Database: Prisma with Neon (serverless PostgreSQL)
- Auth: Better-Auth
- API: tRPC
Issues Encountered
1. @t3-oss/env-core TypeScript inference error on Vercel
The Vercel build fails with type errors in packages/env/src/server.ts:
Type 'ZodString' is not assignable to type '`DATABASE_URL should not prefixed with ${string}.`'
Root cause: createEnv({ server: {...} }) without clientPrefix causes TypeScript to infer TPrefix as string instead of undefined, triggering the ServerOptions error branch for every env var.
Workaround: Add clientPrefix: "" and client: {} to the createEnv call:
export const env = createEnv({
clientPrefix: "",
client: {},
server: {
DATABASE_URL: z.string().min(1),
// ...
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});2. Runtime module resolution failure on Vercel
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/apps/server/node_modules/@fuelops-v2/api/src/context.ts'
Root cause: Workspace packages (packages/api, packages/auth, packages/db) export raw .ts files via their exports field. Vercel's runtime tries to resolve these at runtime but Node.js cannot import .ts files natively. The tsdown build bundles workspace packages (via noExternal), but Vercel ignores the bundle and runs the source directly.
3. No Vercel deployment configuration included
The generated project has no vercel.json or deployment setup for the Hono server. Vercel's zero-config Hono detection doesn't work with this monorepo structure because of the workspace .ts import issue above.
Solution Required
To deploy the Hono server to Vercel, all of the following are needed:
- Fix the env type inference — add
clientPrefix: ""andclient: {}to server env config - Bundle all dependencies in tsdown — change
noExternal: [/@fuelops-v2\/.*/]tonoExternal: [/^(?!node:)/]so the output is fully self-contained - Create a Vercel entry point (
src/vercel.ts) that adapts Hono to Node.js(IncomingMessage, ServerResponse)handler format - Add a second tsdown entry for the Vercel handler
- Use the Vercel Build Output API — create
.vercel/output/structure with a script, sincebuildCommandandbuildsinvercel.jsonconflict - Add
vercel.jsonwithbuildCommand,framework: null
Suggested Fix
Consider adding a Vercel deployment option to the CLI that generates:
- A
vercel.jsonwith properbuildCommandandframework: null - A
src/vercel.tsentry point with the Node.js ↔ web standard adapter - A
scripts/prepare-vercel.mjsBuild Output API setup script - Updated
tsdown.config.tswith full dependency bundling - The
clientPrefixfix in the env package
Or at minimum, document these deployment requirements for Vercel.
Environment
create-better-t-stackversion: latest (as of Feb 2026)- Node.js: 24.13.0 (Vercel build environment)
- TypeScript: 5.9.3
- Vercel CLI: 50.18.2
Activity
duwscan commentedon Mar 26, 2026
Same here
marcusthuressonn commentedon Mar 27, 2026
@KingJune28 did you get it to work on your end? I cannot get it to work on my end, do you have a repo that I can have a look at?
AmanVarshney01 commentedon Oct 21, 2026
Vercel deploys of a separate Hono server in the monorepo were fixed end to end in #1261 (startup crash, /api 404s, module resolution). The old env package was replaced by Varlock in #1224. If you still see this on the latest version, please reopen or open a new issue with the details.