Using the same Convex deployment for 2 different projects
howdy friends! been a while 🙂 question - is there any recommendations for using the same convex deployments for 2 different projects? i.e. a nextjs UI and a nodejs daemon
5 Replies
hey there! would you keep these in the same repo, just different directories+package.json+tsconfigs?
i think so
oh right the convex directory has its own tsconfig doesnt it?
yeah
i'm thinking about this, I haven't played with it before
it's doable, but our codegen isn't set up for it yet. let's see, I think I'd do codegen in whichever package has the
convex/
directory in it, then maybe import the API from ../project/convex/_generated/api
and use that to type everything
and with a bit of TypeScript gymnastics that could get you there
I think there might be trouble if you try to import e.g. useQuery
from ../project/convex/_generated/api
, but also it might just work. My worry is that it will use the copy of React in the other project. If you just import the types you should be safe from any of these shenanigansyeah i run into trouble right when i import useQuery haha
if you look at the
convex/_generated/react.d.ts
file you'll see the code you should put in your other project that is just importing API
something like