Jack Fischer
Jack Fischer2y 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
trash2y 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 Fischer2y 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
trash2y 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 Fischer2y ago
Got it thanks!!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julius
julius2y ago
@latest uses v10 now too 🙂