Tsabary
CDCloudflare Developers
•Created by Tsabary on 4/20/2025 in #pages-help
How do you properly deploy a Next.js app with dynamic routes to Cloudflare Pages?
I’m using Next.js 15 with the new app/directory and trying to deploy my project to Cloudflare Pages using @/cloudflare/next-on-pages. It's a pretty simple project not much going on (repo link below).
I've got cloudflare pages connected to the repo an I selected the basic Next.js Framework preset for the build configuration.
The build command is:
npx @/cloudflare/next-on-pages@1
The issue starts with dynamic routes - for example, I have pages like:
/[channelId]
/[channelId]/[threadId]
When I try to build the project for Cloudflare, I get this error:
javascriptCopyEditThe following routes were not configured to run with the Edge Runtime:
- /[channelId]
- /[channelId]/[threadId]
Please make sure that all your non-static routes export the following edge runtime route segment config:
export const runtime = 'edge';
So, I add export const runtime = 'edge' to those page files, and then everything breaks.
The build fails with this error:
Attempted import error: 'useState' is not exported from 'react'
But the components using useState are marked "use client" correctly. Even trying to dynamically import them with ssr: false doesn't work, because that’s not allowed in server components. I’ve tried wrapping them in a separate "use client" file and importing that, but the issue persists.
I understand that the Edge Runtime uses a stripped-down version of React without client hooks, but I can't figure out how to isolate the client-only components correctly so I can still render the rest of the page with SSR (for SEO).
So:
How are we actually supposed to use dynamic pages with client-side components under the Edge Runtime?
Is this even possible on Cloudflare right now with Next 15?
The exact same repo is connected to Vercel and builds just fine but I'd rather have it on Cloudflare.
Any real-world examples or workarounds?
Appreciate any help.
Project GitHub repo: https://github.com/tsabary/discord-board
2 replies
CDCloudflare Developers
•Created by Tsabary on 3/23/2025 in #general-help
I'm having trouble connecting my domain to my new Cloudflare Pages project
I'm having trouble connecting my domain to my new Cloudflare Pages project. The domain was previously pointed to Webflow, but I’ve since canceled my Webflow plan and removed all related DNS records. Despite that, Cloudflare Pages still shows an error saying the domain is already associated with an existing project. I've contacted Webflow support to confirm the domain is removed on their end, but I'm not sure if there's anything else I need to do on Cloudflare's side to fully disassociate it. Any suggestions on how to fix this so I can attach the domain to my current Pages project would be greatly appreciated!
It's been about 24 hours already since I've removed the records and first tried
3 replies