Setting up Drizzle with Supabase in Next.js App Router
Hey Drizzle Team,
absolutely love what you are building, but i run into a few problems setting it up. I am using Next.js App router and Supabase. This is my current setup:
drizzle.config.ts
/src/app/db/index.ts
/src/app/db/schema.ts
---
Now i want to create a new entry in my db on the click of a button and tried this:
But i am always running into this error:
Any help would be appreciated a lot!! Thank you so much
6 Replies
Looks like an import issue
@Nils man did u find the error? i am stuck here as well
You can't use Postgres on the client. You will have to implement a server route to do this and call it from the client or better still use Server Actions.
@sliderx212x is right. But i have a similar issue, i'm using server actions to make a call to the db from a client component, and i got the same error can't resolve fs, like if i'm call it from the client. I used server action before and i'm pretty sure i'm using it in the right way, i have a form i na client component, which call a server action via action={serverAction}, and the server action is in a separate file marked as "use server".. anyone can help me please?
It's possible your problem is related to edge runtime, where fs is not supported.
server actions inherit the runtime from the page or layout they are called from, so make sure you do have do not have
export const runtime = 'edge'
in your page or layoutEhy thanks @hafffe but I’ve checked and there is no edge runtime.. I tryied to update next to the latest, now everything works, but in the console I still see a fetch, with a 200 response..is this the aspected behavior? To me this sound like a fetch from the client..