Cloudflare Worker with Svelte Frontend

This project sets up a Cloudflare Worker with a Svelte frontend using the latest tools.


βœ… Prerequisites

Make sure you have the following installed:

To install Wrangler globally:

npm install -D wrangler@latest

πŸš€ Setup

1. Create a new Cloudflare Worker with Svelte

npm create cloudflare@latest -- <name-of-worker>

Follow the prompts and select Svelte when asked for a template.

2. Replace Svelte Page

Replace the file at:

my-svelte-app/src/routes/+page.svelte

with your custom version from the worker.

3. Deploy

npm run deploy

Your worker should now be live.


🌐 Worker Address

You can access the deployed app at:

https://worker-svelte.alireza78-bk.workers.dev/

πŸ“ Project Structure (after setup)

my-svelte-app/
β”œβ”€β”€ src/
β”‚   └── routes/
β”‚       └── +page.svelte    <-- Replace this file
β”œβ”€β”€ wrangler.toml
β”œβ”€β”€ package.json
└── ...

πŸ›  Notes

  • Be sure to set up any required environment variables using:
npx wrangler secret put <YOUR_SECRET_NAME>
  • For API calls from the frontend, use relative paths or Workers’ full URLs depending on your setup.

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes