Best way to setup Takumi in a Next.js Project on Cloudflare Workers? #282
|
In my project I have a custom /next/og endpoint (using Takumi core and returning a NextResponse) that I use to generate OG images for [...slug] catch all routes. I've been working on moving off of vercel to Cloudflare Workers via Opennextjs, however I haven't been able to get Takumi to work. Apparently @takumi-rs/core doesn't work in Workers (process.report.getReport method is not implemented). Do you think I (beginner but willing to learn) should try getting it to work (if you're accepting PRs) or should I setup a separate worker based on @takumi-rs/wasm? |
Replies: 11 comments 7 replies
|
Are you using Turbopack or Webpack now? I haven't figured out how to load wasm in turbopack as well. I'd suggest a separated worker setup as temporary solution. |
|
Btw takumi might use over free plan 10ms cpu limitation (depends on your image size and complexity) |
|
I've found ways to import for turbopack, will release later |
|
check again! https://takumi.kane.tw/docs#edge-runtime--browser |
|
Hey @kane50613! Thanks for looking into this. I'm not sure if I'm missing something, but in my case I can't get it to work with any of the two (webpack & turbopack). I need takumi in a OG image API route in a Nextjs (v15.4.4) project on Cloudflare Workers (via Opennextjs). Following the webpack config in the docs:Next config: /api/og/route.tsx: I get: Following the new turbopack config in the docs:Swapped import: Running
|
|
If you want to deploy to Workers, you have to always use edge runtime |
|
I'm confused. The Opennextjs docs literally say to remove any |
|
I'm not exactly sure what it behaves in nextjs 15, the example project is built with nextjs 16 there might be some difference in how turbopack handles wasm module import |
|
Alright, so I was able to get it to work by serving the Takumi ImageResponse from the Worker serving the nextjs project. Works like a charm! |
|
glad to hear! |
|
Hi @kane50613 , I wonder if using the WASM renderer with a |
check again! https://takumi.kane.tw/docs#edge-runtime--browser