|
14 | 14 |
|
15 | 15 | ## Quick Start |
16 | 16 |
|
| 17 | +To get started quickly with a Hello World worker, run the command below: |
| 18 | + |
17 | 19 | ```bash |
18 | | -# Make a javascript file |
19 | | -echo "export default { fetch() { return new Response('hello world') } }" > index.js |
20 | | -# try it out |
21 | | -npx wrangler dev index.js |
22 | | -# and then deploy it |
23 | | -npx wrangler deploy index.js --name my-worker |
24 | | -# visit https://my-worker.<your workers subdomain>.workers.dev |
| 20 | +npx wrangler init my-worker -y |
25 | 21 | ``` |
26 | 22 |
|
27 | | -## Create a Project |
| 23 | +For more info, visit our [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/) guide. |
28 | 24 |
|
29 | | -```bash |
30 | | -# Generate a new project |
31 | | -npx wrangler init my-worker --no-delegate-c3 |
32 | | -# try it out |
33 | | -cd my-worker && npm run start |
34 | | -# and then deploy it |
35 | | -npm run deploy |
36 | | -``` |
| 25 | +## Documentation |
37 | 26 |
|
38 | | -## Installation: |
| 27 | +For the latest Wrangler documentation, [click here](https://developers.cloudflare.com/workers/wrangler/). |
39 | 28 |
|
40 | | -```bash |
41 | | -$ npm install wrangler --save-dev |
42 | | -``` |
| 29 | +To read more about Workers in general: |
43 | 30 |
|
44 | | -## Configuration: |
| 31 | +- [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/) |
| 32 | +- [How Workers works](https://developers.cloudflare.com/workers/reference/how-workers-works/) |
| 33 | +- [Observability](https://developers.cloudflare.com/workers/observability/) |
| 34 | +- [Platform](https://developers.cloudflare.com/workers/platform/) |
45 | 35 |
|
46 | | -Wrangler is configured via a `wrangler.json` or `wrangler.toml` file in the project root. When utilizing the `wrangler init` command, a `wrangler.toml` file will be created for you. |
| 36 | +## Configuration |
47 | 37 |
|
48 | | -Example: |
| 38 | +Wrangler is configured via a `wrangler.toml` or `wrangler.json` file in the project root. An example configuration generated by `npx wrangler init` or `npx create cloudflare` is as follows: |
49 | 39 |
|
50 | 40 | ```toml |
51 | 41 | name = "my-worker" |
52 | | -main = "./src/index.ts" # init w/ TypeScript |
| 42 | +main = "./src/index.ts" |
53 | 43 | compatibility_date = "YYYY-MM-DD" |
54 | 44 | ``` |
55 | 45 |
|
56 | 46 | For more detailed information about configuration, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/configuration/). |
57 | 47 |
|
58 | 48 | ## Commands |
59 | 49 |
|
60 | | -### `wrangler init [name]` |
61 | | - |
62 | | -Creates a Worker project. For details on configuration keys and values, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/commands/#init). |
| 50 | +### Workers |
63 | 51 |
|
64 | | -### `wrangler dev` |
| 52 | +#### `wrangler dev` |
65 | 53 |
|
66 | 54 | Start a local development server, with live reloading and devtools. |
67 | 55 |
|
68 | | -### `wrangler deploy` |
| 56 | +#### `wrangler deploy` |
69 | 57 |
|
70 | | -Publish the given script to the worldwide Cloudflare network. |
| 58 | +Publish the given script to Cloudflare's global network. |
71 | 59 |
|
72 | 60 | For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/commands/). |
73 | 61 |
|
74 | | -## Pages |
| 62 | +### Pages |
75 | 63 |
|
76 | | -### `wrangler pages dev [directory] [-- command]` |
| 64 | +#### `wrangler pages dev [directory]` |
77 | 65 |
|
78 | | -Either serves a static build asset directory, or proxies itself in front of a command. |
| 66 | +Serves a static build asset directory. |
79 | 67 |
|
80 | 68 | Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory. |
81 | 69 |
|
82 | 70 | For more commands and options, refer to the [documentation](https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally) or run `wrangler pages dev --help`. |
83 | | - |
84 | | -## Documentation |
85 | | - |
86 | | -For the latest Wrangler documentation, [click here](https://developers.cloudflare.com/workers/wrangler/). |
0 commit comments