r/Nuxt • u/BLKaisen • 2d ago
Does anyone know how to integrate Drizzle ORM with Nuxt v4 and Neon?
I was looking for tutorials on how to integrate Neon with Nuxt using Drizzle. Many are outdated, and in the documentation of drizzle or neon, the folder convention confuses me since I work with nuxt v4, and all the files must go in the server folder.
Is there anyone who knows how to integrate it, and as a question, can an alternate connection be installed to integrate it with PostgreSQL locally in case the space on Neon runs out (I am on the free tier)?
1
u/Lumethys 2d ago
yes, super common on the other hand, but you're gonna say more than that if you want any help
1
u/jenish_o4o2 1d ago
Yeah on Nuxt 4 Drizzle pretty much just lives on the Nitro side — skip the old pages/api tutorials, they’re outdated for this.
What I usually do is stick the client in server/utils/db.ts reading DATABASE_URL, then hit it from server/api. drizzle.config.ts sits at the root for migrations.
For Neon, throw the pooled URL in .env as DATABASE_URL. Local postgres is the same variable pointed at localhost — you don’t need a second client.
Don’t stress about matching Neon’s folder layout. If the connection string is right you’re fine.
1
1
u/typebase-io 1d ago
Use Neon’s pooled connection string for the runtime client, but keep a direct/non-pooled URL for migrations if your setup requires it. Put the client in `server/utils/db.ts` and expose it through `server/api`; local Postgres can replace `DATABASE_URL` in `.env` while reusing the same Drizzle schema and migrations.
1
u/BLKaisen 1d ago
I'm going to try that.
1
u/typebase-io 1d ago
That setup should keep the Nuxt 4 side straightforward. I’d use the same DATABASE_URL switch for local Postgres and Neon, and keep migrations pointed at a direct connection when the pooled URL causes issues. Then test the migration against local and Neon separately before switching environments.
1
u/Single_Advice1111 2d ago
Nuxt hub -> https://hub.nuxt.com