Server folder in create-t3-app
I am not using nextjs custom server (server folder).I am using my backend code api.
Is there any way to create-t3-app without it,or I need to delete it and manage the files there on my own?
12 Replies
Just generate a t3 app with tailwind only
But if I want to use trpc? @Ronan
Why would you not want to use the server folder to separate your routers then?
I use the api points @julius
Inlining router in the trpc slug file will get very messy after some time
Well yes the slug route will expose the api but its good practice to separate the router into multiple files
So for what usage I have api folder and server folder...i mean when to use each? @julius
trpc expose all your procedures under a single next api endpoint
this is your next api endpoint https://github.com/trpc/trpc/blob/main/examples/next-prisma-starter/src/pages/api/trpc/%5Btrpc%5D.ts
GitHub
trpc/[trpc].ts at main · trpc/trpc
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/[trpc].ts at main · trpc/trpc
and you pass in your router
https://github.com/trpc/trpc/blob/main/examples/next-prisma-starter/src/server/routers/_app.ts which you by good practice define in the server directory
GitHub
trpc/_app.ts at main · trpc/trpc
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/_app.ts at main · trpc/trpc
that
export default trpcNext.crerateNextApiHandler
is a next api endpoint handler export default function handler(req, res) { // magic in here }
that handles all the requests you define in your router's proceduresGot you!!!
Thanks