Next.js Discord

Discord Forum

pages vs app router with tRPC + SSR

Unanswered
American Sable posted this in #help-forum
Open in Discord
American SableOP
I am currently doing some research for a new work project to determine the feasability of using Next.js (first time) with tRPC and either the pages or app router while still being able to leverage SSR.

What are the main pros and cons of the pages or app router?
What about when tRPC is used with either?
What if we want SSR for those tRPC requests?
If SSR isn't feasible with tRPC or if the config will make it difficult for a team new to Next to adopt, what are the alternatives? Do regular REST API requests work with SSR? Are we better off using tRPC on the client only? Ideally we can still use react-query even if we can't tRPC.

It is hard to tell at this point if we will actually need to utilize the app router for things like changing the route when a tab changes in the UI, but the other features of the app router along with the possibility of file colocation (and it seems app router is the future anyway), ideally we would use the app router for the new project.

Sorry for all the questions. Next.js seems to be evolving very quickly and while I have been trying to follow along with news, this will be the first real-world attempt at a team-based project.

4 Replies

mental model changed a lot in App Router, where responses are Wired Format chunks. you might want to create a hello world project, then call endpoints with cURL. you know what i mean.
and you might want to clarify your definition of SSR. maybe you get it wrong.
or different from Next.js folks use.
Citrus blackfly parasitoid
I've decided to switch to using pages instead of the App Router because I've been facing challenges while working with middlewares in the App Router. Despite searching extensively, I couldn't find any relevant documentation, support on Stack Overflow, Reddit, or other platforms for assistance with this API. Even ChatGPT couldn't provide the necessary help. I've reached a point of frustration, and I'm now downgrading from the App Router to Pages.