how to integrate function in Next.js ssg app folder project

Hello ,i have write in api/route.js but the result will prefetched get same result using export const runtime = "edge"; can we have next.js without ssr but with dynamic api?
6 Replies
Hello, I’m Allie!
If you enable Next's Static Export mode, and don't use @cloudflare/next-on-pages, then you can just use Functions like normal.
jj8822
jj8822OP16mo ago
Thank you a lot for your help,can you explain more ? I have enabled Static Export and don’t have @Not Cloudflare :)/next-on-pages but can’t have functions working(will only generate a static json file),I’m using app router
Hello, I’m Allie!
Are you using Pages Functions, or something else? Because these should work fine in a static export.
jj8822
jj8822OP16mo ago
I have used this https://nextjs.org/docs/app/building-your-application/routing/route-handlers tested this https://developers.cloudflare.com/pages/platform/functions/get-started/ now but seem not working with Nextjs’s App router ,get all time 404
Routing: Route Handlers
Create custom request handlers for a given route using the Web's Request and Response APIs.
Get started · Cloudflare Pages docs
This guide will instruct you on creating and deploying a Pages Function.
Hello, I’m Allie!
As far as I can tell, Route Handlers would only work with next-on-pages, so they wouldn't work here.
jj8822
jj8822OP16mo ago
Thank your for your help,I successfully made it working following the guide that your put above https://developers.cloudflare.com/pages/platform/functions/get-started/ Previously I get 404 because I have putted the functions directly under app folder, moving it in the root directory make all things workings
Get started · Cloudflare Pages docs
This guide will instruct you on creating and deploying a Pages Function.
Want results from more Discord servers?
Add your server