Next.js Discord

Discord Forum

Using drizzle in monorepo

Answered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
I am building a project where I have 2 next.js applications. Let's call them admin and web. The admin is responsible for CRUD operations to database and allows the admin user to manage content on their website, while web interacts with the database in a read-only way, displaying the content for the user.

I want to share a single drizzle db client between both projects because this keeps types for both projects synced and I don't have to write changes in 2 places whenever I want to modify something schema related.

How can I achieve such a thing in a turbo monorepo or any other way?
Answered by "use php"
So assuming this is the file structure:
apps/web
apps/admin

You can create the DB on

packages/bot

and import it.

The same is being used by the bot @Oriental .
you can view src at https://github.com/rafaelalmeidatk/nextjs-forum
View full answer

5 Replies

Answer
Sun bearOP
thank you very much