Database Setup & Connections
Configure and manage your database.
This section guides you through setting up and connecting to your Supabase PostgreSQL database, which serves as the backbone for Plainform data storage.
Plainform uses a Supabase PostgreSQL instance for its database. To connect your application, you must configure the DATABASE_URL environment variable with the connection string provided by Supabase. The t3-env library validates this variable at runtime to ensure a successful connection; if missing or invalid, the app will not start.
Steps to Set Up and Connect
Create a Supabase Project
- Sign up at Supabase and create a new project.
- Navigate to Settings > Database in your Supabase dashboard to find your connection string.
Configure the Environment Variable
- Copy the PostgreSQL connection string (e.g.,
postgresql://postgres:[YOUR-PASSWORD]@db.your-project-ref.supabase.co:6543/postgres?pgbouncer=true). - Add it to your
.envfile (or.env.localfor development):
DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.your-project-ref.supabase.co:6543/postgres?pgbouncer=true- Ensure the
.envfile is listed in.gitignoreto avoid exposing sensitive credentials.
Verify Connection
- Sign up at Supabase and create a new project.
- Navigate to Settings > Database in your Supabase dashboard to find your connection string.
Configure the Environment Variable
- Run
npm run devto start your app. Thet3-envvalidation inenv.mjswill check theDATABASE_URL. - If the connection fails, confirm the string format and network access (Supabase allows connections from your app’s IP).
Supabase’s dashboard provides tools to manage your database, such as creating tables or exploring data. Ensure your DATABASE_URL includes the correct credentials and host to avoid connection errors.
How is this guide ?
Last updated on