API Layer with App Dir
Hi all,
With tRPC still in limbo with the new app directory, I’m tempted to go back to GraphQL as my API layer for new projects going forward.
I love tRPC for the most part, but having a backend so tightly coupled to the inner workings of Next.js means that significant changes (like the app directory) now seems risky to me. I’ve played with tRPC in Next.js 13.4 using the “hacks” floating around online, but none seem to have that “magic” that tRPC had back in the pages directory.
I’m curious what you all are currently using for new projects. Are you switching API layers? Are you moving to the app directory? Do we even need APIs anymore? I want to know your thoughts.
2 Replies
The app dir projects I have seen around or they use a basic API request with casting
Or they use some sdk/edge orm to make operations
Something like drizzle, or maybe a pocketbase, or whatever you need
The problem isn’t APIs or fetching data, both tRPC and other solutions do that just fine in the app dir
It’s people’s expectations around state management and invalidation