Jack Fischer
Jack Fischer3y ago

Recommended file structure for next.js?

Hey all - using tRPC heavily with next.js and it's great. Our main [trpc].ts file is getting huge and unwieldily - wondering what the recommendations are out there for organizing?
6 Replies
trash
trash3y ago
hi, have you checked out this next example https://github.com/trpc/trpc/tree/next/examples/next-prisma-starter also check out the docs here: https://trpc.io/docs/v10/nextjs theres a recommended file structure section
Jack Fischer
Jack FischerOP3y ago
Hey thanks a bunch. I think these give you the basic layout but not how to break out [trpc].ts - is it recommended to put individual query/mutations in that same trpc directory for example?
trash
trash3y ago
i believe the starter projects shows you how to break up your routers and keep them outside the [trpc].ts file https://github.com/trpc/trpc/blob/next/examples/next-prisma-starter/src/pages/api/trpc/%5Btrpc%5D.ts the server folder structure: https://github.com/trpc/trpc/tree/next/examples/next-prisma-starter/src/server
Jack Fischer
Jack FischerOP3y ago
Got it thanks!!
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
julius
julius3y ago
@latest uses v10 now too 🙂

Did you find this page helpful?