-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Adds more details to overview, basic workflow, and How it works section #19508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
41a5874
fbba83f
7b760ad
7dd6bbe
acf2961
122c2c2
d32e32d
c337adf
51eaaf6
c2b7fca
10c00c8
d52902c
a809133
feeea0f
414f5f4
78a0bc7
c41babf
e8dc03e
4e79672
b730fd1
40f1967
e8d96d9
879227c
3aefe38
e693569
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,9 @@ description: Create full-stack applications deployed to Cloudflare Workers. | |||||
| --- | ||||||
|
|
||||||
| import { | ||||||
| Aside, | ||||||
| Badge, | ||||||
| Details, | ||||||
| Description, | ||||||
| InlineBadge, | ||||||
| DirectoryListing, | ||||||
|
|
@@ -21,35 +23,147 @@ import { | |||||
| LinkButton, | ||||||
| Stream, | ||||||
| Flex, | ||||||
| WranglerConfig, | ||||||
| Steps, | ||||||
| } from "~/components"; | ||||||
|
|
||||||
| <Description> | ||||||
| Create fast, scalable front-end applications deployed to Cloudflare Workers. | ||||||
| </Description> | ||||||
| Cloudflare Workers simplify hosting and serving static like (such as HTML, CSS, images, and other resources) by combining a globally distributed CDN with lightweight, serverless backend logic. | ||||||
|
|
||||||
korinne marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| With Workers, you can: | ||||||
korinne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| - **Host static sites** or **Single Page Applications (SPAs)** across Cloudflare's network. | ||||||
korinne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| - **Add backend logic** (such as APIs or custom middleware) alongside your assets without needing a dedicated server. | ||||||
|
|
||||||
| - Serve content to users with **low latency** using **built-in caching** for faster load times for users worldwide. | ||||||
|
|
||||||
| - **Build full-stack applications** using Cloudflare's storage solutions, such as [R2](/r2/) for object storage, [KV](/kv/) for distributed key-value storage, [D1](/d1/) for relational databases, and [Durable Objects](/durable-objects/) for stateful, consistent storage and coordination. You can also connect to existing databases using [Hyperdrive](/hyperdrive/) | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Basic Workflow | ||||||
|
|
||||||
| --- | ||||||
korinne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| From a high-level, here's how you can get started with deploying a simple static site on Workers: | ||||||
korinne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| <Steps> | ||||||
| 1. Build your static assets. | ||||||
| ```sh | ||||||
| npm run build | ||||||
| ``` | ||||||
| <Details header="Don't have an existing project?"> | ||||||
| You can quickly scaffold a project using [Vite](https://vite.dev/guide/#scaffolding-your-first-vite-project): | ||||||
| ```sh | ||||||
| npm create vite@latest | ||||||
| ``` | ||||||
| And follow the prompts! For first-timers, just select `vanilla` as your template. | ||||||
|
||||||
| </Details> | ||||||
| 2. Add and configure a Wrangler configuration file (`wrangler.toml` or `wrangler.json`) | ||||||
|
|
||||||
| <WranglerConfig> | ||||||
| ```toml | ||||||
| name = "my-static-site" | ||||||
| compatibility_date = "2025-01-01" | ||||||
| [assets] | ||||||
| directory = "./dist" | ||||||
| ``` | ||||||
| </WranglerConfig> | ||||||
|
|
||||||
| In this configuration file, you define the **directory** where Cloudflare can find your built assets that need to be uploaded. To do this, we've added an `[assets]` block, and specified the `directory` as `dist/`. | ||||||
|
|
||||||
| 3. Deploy with Wrangler | ||||||
|
|
||||||
| ```sh | ||||||
| npx wrangler deploy | ||||||
| ``` | ||||||
|
|
||||||
| And let Cloudflare Workers handle asset uploading, routing, and caching automatically! | ||||||
korinne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| </Steps> | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## What you can build | ||||||
| ## How it works | ||||||
|
|
||||||
| When you deploy your app with Wrangler, it deploys both your Worker script and your static assets in a single operation. This deployment operates as a tightly integrated "unit" running across Cloudflare's network, combining static file hosting, custom logic, and global caching. | ||||||
|
||||||
| When you deploy your app with Wrangler, it deploys both your Worker script and your static assets in a single operation. This deployment operates as a tightly integrated "unit" running across Cloudflare's network, combining static file hosting, custom logic, and global caching. | |
| When you deploy a Worker to Cloudflare that has static assets, it deploys both your Worker's code and your static assets as one integrated "unit" running across Cloudflare's network, combining static file hosting, custom logic, and caching. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would suggest cutting or tightening paragraphs below
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Static asset hosting on Workers allows you to serve files such as HTML, JavaScript, CSS, images, and other resources directly from Cloudflare's global network. This setup eliminates the need for a traditional web server, simplifying deployment and optimizing performance. |
Think repeating?
korinne marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip suggests this is nice-to-have optional, would expect somewhere to enumerate — what are the configuration options and what do they mean?
Uh oh!
There was an error while loading. Please reload this page.