T
TanStack10mo ago
foreign-sapphire

Using Next js and GRPC

I'm interning at a friend's startup building a SaaS for textile companies. The backend is in Go with gRPC, and I’m handling the frontend. While Angular is the proposed framework, I'm more comfortable with Next.js, which offers easy server-side rendering and data prefetching—crucial for our data-heavy tables and pagination. I’m exploring options like React Query or tRPC for managing data fetching, but I need to integrate them with gRPC without adding unnecessary complexity. What’s the best approach to efficiently prefetch data, handle pagination, and communicate with gRPC in this context? Anyone worked in a similiar codebase?
1 Reply
national-gold
national-gold10mo ago
Not heard of a lot of gRPC straight to frontend, but you could give this a shot https://grpc.io/docs/platforms/web/basics/ I'll be straight I can't figure out how you would put this in a query function. You other two options is to do a BFF, so call the gRPC code in a seprate backend (for NextJs API routes or Server Components, tRPC, or createServerFn if your willing to play with TanStack start) or you create OpenAPI or GraphQL endpoints on the Go Server.
gRPC
Basics tutorial
A basic tutorial introduction to gRPC-web.

Did you find this page helpful?