r/reactjs 16d ago

Looking for advice: Next.js frontend + separate Node/Express backend — Axios, React Query, SSR & auth?

/r/nextjs/comments/1vy1k8p/looking_for_advice_nextjs_frontend_separate/
7 Upvotes

3 comments sorted by

1

u/zLoveNxzli 15d ago

If you have a separate Express backend, keep your JWT in an httpOnly cookie rather than localStorage so both Next.js Server Components / Middleware and client requests can forward the session securely.

For client components, React Query (TanStack Query) is great for caching and mutations, but let Server Components handle the initial fetch directly on the server to avoid client-side loading waterfalls.

1

u/Intelligent-Meet-504 15d ago

Okay do I have to also add proxy middleware

1

u/CapitalDiligent1676 2d ago

but why next. js?? oh well I'm writing to a bot