Use Supabase with Next.js
Learn how to create a Supabase project, add some sample data to your database, and query the data from a Next.js app.
Set up a Supabase project with sample data
Create a new project in the Supabase Dashboard.
After your project is ready, create a table in your Supabase database using the SQL Editor in the Dashboard.
Use the following SQL statement to create a countries
table with some sample data.
Create a Next.js app
Use the create-next-app
command and the with-supabase
template, to create a Next.js app pre-configured with:
Declare Supabase Environment Variables
Rename .env.local.example
to .env.local
and populate with your project's URL and Anon Key.
Query Supabase data from Next.js
Create a new file at app/countries/page.tsx
and populate with the following.
This will select all the rows from the countries
table in Supabase and render them on the page.
Start the app
Run the development server, go to http://localhost:3000/countries in a browser and you should see the list of countries.