NEXTJS: module not found: net
hey guys, i've been trying drizzle with react query within the app router. everything works great on the server components, but it throws an error: 'module net is not defined' when i try to use the same query function on the client. ill provide some code:
this is how i create my drizzle client:
this is my query function (works on server but not on client):
this is how im fetching data on page.tsx (works fine)
this is how im fetching on client component (throws module not found error):
why does it throw an error when fetching client side? is there any way i can use the same query function server and client side? or do i have to create an api endpoint for client side fetching? thanks!
1 Reply
I don't think you can use db on the client. And since getProvncias is using it, which you are directly using on the client, you would expect some errors.
You can do either of these:
- Create an api endpoint for querying the database and create a function that fetches that endpoint.
- Create a server action, some people don't recommend this when you're dealing with authentication and sensitive info (such as api keys)