Hasty Briefsbeta

Next.js Is Infuriating

8 days ago
  • #frustration
  • #logging
  • #Next.js
  • The author decides to write a blog post after long hesitation, motivated by frustration.
  • The post discusses setting up production-ready logging in a Next.js service, highlighting challenges with middleware and logging libraries like pino.
  • Initial attempts to use middleware for logging fail due to limitations in passing data (only headers can be modified) and issues with AsyncLocalStorage not persisting context across middleware and page renders.
  • A workaround involves using headers to pass a request ID, but this leads to convoluted and split logging code between middleware and server components.
  • The author explores using a custom Next.js server but finds that AsyncLocalStorage still doesn't work as expected, with logging from the server not appearing in the expected context.
  • Frustration mounts as the author compares Next.js unfavorably to SvelteKit, which offers more straightforward and flexible middleware and logging capabilities.
  • The post criticizes Next.js's GitHub issue tracker for being unresponsive, with many bugs reported years ago still unresolved.
  • The author concludes by expressing a desire to move away from Next.js due to persistent bugs, poor tooling, and lack of solutions to fundamental problems.