Search code examples
cloudweb-development-serververcel

Access database from a deployed Next Application


I'm new to web development and currently learning Next, my question is how will I be able to access the my database (PostgreSQL) once I've deployed my application (both from and back) to Vercel.

Is there anyway, or should I create an API prior to deployment that will generate a report for the contents of my DB.


Solution

  • You can access your database from your Vercel deployment the same way you access it from local development on your machine, by setting Environment Variables.

    With Next.js, you can create a .env.local file with names/values and use those with next dev.

    With Vercel, you add those names/values to in the Project Settings under Environment Variables.