ixartz / Next-js-Boilerplate

🚀🎉📚 Boilerplate and Starter for Next.js 14+ with App Router and Page Router support, Tailwind CSS 3.4 and TypeScript ⚡️ Made with developer experience first: Next.js + TypeScript + ESLint + Prettier + Drizzle ORM + Husky + Lint-Staged + Vitest + Testing Library + Playwright + Storybook + Commitlint + VSCode + Netlify + PostCSS + Tailwind CSS ✨
https://nextjs-boilerplate.com
MIT License
8.7k stars 1.67k forks source link

Unable to read/write to Postgres Database #288

Closed mzavattaro closed 1 month ago

mzavattaro commented 1 month ago

Great boilerplate. We're currently looking at using it internally for a grass roots project and I'm testing it out to understand how it works.

The issue I'm having is that I can't get it to read/write to our Neon Postgres database. I can successfully get it to npx drizzle-kit generate new tables into Neon, but I can't seem to get it to write guestbook entries into the database or read entries from the database guestbook table. It doesn't throw any exceptions.

I've got the connection string DATABASE_URL=postgresql:// in the .env file (.env.local and .env.production.local doesn't locate the database url). Network requests are showing status 200 for all the POST requests from the guestbook form.

You can check out my fork here: https://github.com/mzavattaro/Next-js-Boilerplate

I'm sure I'm missing something simple, any help would be great.

ixartz commented 1 month ago

By default, on local/dev environment, the project uses the local and in-memory PostgreSQL database. This should explain why the Neon database don't contain any data.

The best way is to deploy the project and use Neon database, you should able to see the data.

mzavattaro commented 1 month ago

Ah okay gotcha, so once it's deployed then I'll be able to see the data from Neon locally?

ixartz commented 1 month ago

Once it's deployed, you can see the Neon data on the deployed/production version