How to use worker with an existing application

I currently have a react code base and i want to deploy i to Cloudflare worker. Can someone refere me on how to augment existing application.
12 Replies
Hello, I’m Allie!
Is the React app static?
Lamodot
LamodotOP9mo ago
No not static
Hello, I’m Allie!
What are you using for the server? Next.js?
Lamodot
LamodotOP9mo ago
Am uisng Vike app like Next.js
Hello, I’m Allie!
GitHub
vike/examples/cloudflare-workers-react at main · vikejs/vike
🔨 Like Next.js / Nuxt but as do-one-thing-do-it-well Vite plugin. - vikejs/vike
Hello, I’m Allie!
Should be as simple as
import { renderPage } from 'vike/server';

export default {
async fetch(req) {
return await renderPage(req);
}
}
import { renderPage } from 'vike/server';

export default {
async fetch(req) {
return await renderPage(req);
}
}
or something
Lamodot
LamodotOP9mo ago
Have looked out this example, It is an app created form gound up with worker. My case is this, I have already worked on an app on Vike and i want to deploy it to woker. How do i go about doing this? Not provided i their example
Hello, I’m Allie!
Do you have a repo for it?
Lamodot
LamodotOP9mo ago
GitHub
GitHub - lamodots/vike-app: play ground
play ground. Contribute to lamodots/vike-app development by creating an account on GitHub.
Lamodot
LamodotOP9mo ago
Did you take a looke at it?
Hello, I’m Allie!
Ok, so looking at it, I'm not actually sure how to adapt it. Tbh, I've never used Vike myself. Maybe try starting with their example that works, and slowly copy over components/pages? Big thing though, don't use node-fetch, since Workers already has the fetch API
Lamodot
LamodotOP9mo ago
Alight
Want results from more Discord servers?
Add your server