Created
March 8, 2026 07:00
-
-
Save fayazara/aa32034dbe46c9aaab1d38e399f5a1a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I have a website I want to deploy to the internet using Cloudflare Workers with Static Assets. | |
| Use Cloudflare Workers (not cloudflare Pages) with the assets configuration instead. | |
| Here's what I need you to do: | |
| 1. Look at my project and figure out how it builds and where the built output files end up (e.g. ./dist, ./build, ./public, ./out, or the root). | |
| 2. Install Wrangler (Cloudflare's CLI): npm install -g wrangler | |
| 3. Log me in: wrangler login | |
| 4. Create a wrangler.toml in the root of my project: | |
| name = "my-website" | |
| compatibility_date = "2026-03-08" | |
| [assets] | |
| directory = "<path-to-build-output>" | |
| Set directory to wherever the final built HTML/CSS/JS files end up. | |
| 5. Build my project if needed, then deploy with: npx wrangler deploy | |
| No Worker script file is needed for a static site -- just the wrangler.toml and the built files. | |
| The site will be live at my-website.<my-subdomain>.workers.dev. | |
| If I ever need server-side logic alongside my static files later, I can add a main entry point and an ASSETS binding: | |
| name = "my-website" | |
| compatibility_date = "2026-03-08" | |
| main = "src/index.js" | |
| [assets] | |
| directory = "<path-to-build-output>" | |
| binding = "ASSETS" | |
| With a src/index.js like: | |
| export default { | |
| async fetch(request, env, ctx) { | |
| return env.ASSETS.fetch(request); | |
| }, | |
| }; | |
| Start by examining my project to determine the build step and output directory, then set everything up. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment