Multi-tenant in Next.js, How to delay the creation of the Drizzle client

I'm using t3 to bootstrap my project and integrating TRPC with Drizzle with app directly. In my multi-tenant application, the database connection URL is determined only after a successful login. However, creating a Drizzle client requires this URL upfront. Challenges 1. Delayed Drizzle Client Creation: I've postponed creating the Drizzle client until I have the connection URL. This step was straightforward. 2. API Construction Issue: The tricky part is constructing the api (api = createCaller(createContext) and api = createTRPCReact<AppRouter>()) without the connection URL. To work around this, I've designed the api as a function. This function receives the connection URL as an argument to create the createTRPCContext. 3. Complexity and Cost: Managing the connection URL across components has proven to be cumbersome and not very efficient. This setup feels costly, especially considering the frequent need to access the URL. any help would be too much appreciated.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server