Wranglers generate command,
wrangler generate, allows you to create new Cloudflare Workers projects. Using the URL parameter, you can also generate new projects based on Cloudflare's starter templates, or open-source projects created by other developers, but for now, you will just use the default. To do this you'll only need to give it a name, for example,
wrangler generate my-worker, this will create a new project called my-worker.
Kristian Freeman: [0:00] Now that you've logged in with Wrangler, it's time to create your first project. To do this, we'll run the wrangler generate command. If I run wrangler generate -h, you can see I get some information about how to actually use this command including some flags, options, and arguments.
[0:16] Here's the basics of wrangler generator. First, you give it a name of your project, for instance, My Worker. Optionally, if you like, you can give it a URL which represents a template.
[0:50] Then, there's more advanced ones. It's like the Worker TypeScript template, which is a batteries included template for kick starting a TypeScript project and workers. There's also things like routers, built-in libraries for routing incoming requests to different functions. Even more advanced things, like a workers-graphql-server, which is a full on Apollo GraphQL server, built on top of Workers. There's all kinds of templates you can use.
[1:17] For now, we'll just use the default. We're not even going to pass in a template or a URL. We'll just say, wrangler generate my-worker. It's going to create a new project called, my-worker. You can see the text is a little faded there, but it just says, creating project called, my-worker. Then I have this new folder/home/kristian/src/my-worker.
[1:40] It gives me a little helpful hint here. You'll need to update the following fields in the created wrangler.toml file, specifically my account_id, which you can see here. For now, I'll just go into my-worker and I'll just look inside here. You can see there's not that much stuff that is add in, CODE_OF_CONDUCT, some licenses, a README.
[2:24] If you're interested in all the other things you can do with Wrangler, you should definitely check out the Commands page which is also in our docs. You just come to the Workers docs, go to CLI (Wrangler) and check out Commands.
[2:36] You can see basically for every single command inside of Wrangler, the different arguments you can pass in, different flags, all different things that you can do here. There's a number of other Commands. Some of which we'll get to in this course. Others, you'll probably have to go check out yourself, or maybe I'll cover in a future lesson.
In case the login doesn't work for someone, please try these steps instead.
wrangler login to open login link.
Press F12, then switch it to network tab.
Press "Authorize Wrangler", then wait it success.
Check the lastest request, find a request like
https://dash.cloudflare.com/api/v4/user/tokens/SOME_HEX_STRING_HERE/value , then find your API token in the response.
wrangler config, paste the API token into it and press Enter, then you will get "Successfully configured. You can find your configuration file at: ..."