Menu

3 rendering bugs my Next.js app only had on Cloudflare Workers
📰

3 rendering bugs my Next.js app only had on Cloudflare Workers

DEV Community: nextjs·Nick Fasulo·6 days ago
#5LGrc9pA
#devtonextjs#devto#dev#code#script
Reading 0:00
15s threshold

I run Galaxy Movies , a Next.js Pages Router app, on Cloudflare Workers via @opennextjs/cloudflare . When I migrated off Vercel, every smoke test passed: pages returned 200, the HTML looked right, the APIs responded. Then Playwright ran against the built bundle and three bugs fell out, all invisible to curl. If you deploy Next.js through any adapter that re-bundles your code, these are worth knowing about.

1. Never build a <script> from fn.toString()

A common theme-init trick is rendering an inline script whose source is a function's .toString() output so that you can write the script as real code instead of a quoted string.

OpenNext builds the worker with esbuild's keepNames enabled, which rewrites function definitions into __name(fn, "fnName") calls to preserve .name through minification. That helper exists inside the worker bundle.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.