3 ms·
The nextjs team for the longest time seemed openly hostile to server-side features in the GitHub issues. We ended up using the custom server feature to essentia
by moojd 4y ago
The nextjs team for the longest time seemed openly hostile to server-side features in the GitHub issues. We ended up using the custom server feature to essentially bypass nextjs entirely so we could adequately do things like server-side auth in an explicit way using existing proven middleware. Next auth was inadequate for us mostly because of the limitations of nextjs itself. Nextjs 13.1 just added actual server-side middleware with full control of requests/responses so hopefully things will improve. I haven't fully investigated it yet but I'm hoping we can rip out all of our custom server stuff and replace it with middleware now.
- sirius87 4y agoSame. I found this example [1] particularly helpful, although I don't know how good this [2] library it uses is. Overall, I've seen multiple OSS projects [3] that try to support a missing functionality in Next.js seem to just give up trying to keep up with their breaking changes. [1] https://stackblitz.com/edit/github-mwzv1t?file=README.md https://stackblitz.com/edit/github-mwzv1t?file=README.md [2] https://github.com/hoangvvo/next-connect https://github.com/hoangvvo/next-connect [3] https://github.com/cyrilwanner/next-optimized-images https://github.com/cyrilwanner/next-optimized-images
- Kiro 4y agoIf you need to bypass Next.js, why use it at all?
- moojd 4y agoWe are using nextjs for everything it can do, while bypassing it for the things it can't. With 13.1 that shouldn't be necessary because it is now more capable.
- deckard1 4y ago> Nextjs 13.1 just added actual server-side middleware the middleware has been available for awhile, they just added a few "advanced" features it looks like. The problem with their middleware is that it's based on their edge runtime. Which is pretty much very basic web APIs and nothing more. Unlike Express/Koa, you do not have the full node API and cannot do things like read files from the filesystem. It's a total unnecessary clusterfuck just so Vercel can get you on their cloud services. Every single day I work with Next.js I wish I had Express and a decent router.
- super256 4y agoI like fastify more than express due to the great opinions (json schema, hooks etc). I use fastify + the fastify-nextjs plugin. It works great and lets you expose custom request decorations from node.js to next.js. Maybe this can help you too: https://github.com/fastify/fastify-nextjs https://github.com/fastify/fastify-nextjs The only drawback is the slow startup time of next.js, which becomes really annoying with huge next.js projects. But for smaller projects, fastify-nextjs is fine.