DEV Community

Cover image for Get Started with Prisma and Nextjs with Supabase (Postgress Database)
Next Dev
Next Dev

Posted on

Get Started with Prisma and Nextjs with Supabase (Postgress Database)

Welcome 👋 brothers and sisters to this amazing blog post where you will learn how to get started with Prisma setup in nextjs.

Things which we will need:

  1. Prisma Client

  2. Nextjs Project

  3. Supabase or Any other database

  4. 😁Enjoyment

**Step1: **Make a Nextjs project and open the terminal

**Step2: **Write this command in the terminal

npm i @prisma/client
Enter fullscreen mode Exit fullscreen mode

Then write this command:

prisma init
Enter fullscreen mode Exit fullscreen mode

Then you will find a new folder named: ‘prisma’ in your root directory.

Now go to ‘schema.prisma

You can see something like this.



Then go to ‘.env’ file in your directory.

You have to paste your database URI there

So, let’s go to supabase to find the URI:

Just paste it into your .env file

Now you can enjoy it. You have set up all the things.

🤔Situation

Now you have two situations. Either you have tables or you don’t have any tables inside your database.

1. If you have tables in your database.

Just write the command

prisma db pull
Enter fullscreen mode Exit fullscreen mode

Then check out the ‘schema.prisma’ file

2. You don’t have any tables in your database.

For example, you can write this command in your ‘schema.prisma’ to make tables.

Code:



Now, you have to write the command

prisma migrate dev
Enter fullscreen mode Exit fullscreen mode

Then it will ask you for your migration name.
You can write there anything you want.

Then you will see one folder as **Migrations **in your **prisma **directory.

You can check your database and see the results.

Thanks for reading this blog post.

For people who Hindi:
https://youtu.be/pnai0oGVN9g

For people who want to join discord:
Join the Next Dev's server Discord Server!

Discussion (0)