You can run your entire application locally with our Wrangler Command Line Interface (CLI). To get started with Wrangler, you can install it with the following command:
$ npm install --global wrangler
The main command for local development on Pages is
wrangler pages dev. This will let you run your Pages application locally which includes serving static assets and running your Functions. If you have a folder of static assets then you can run the following command to start local development:
$ wrangler pages dev <directory-of-assets>
This will then start serving your Pages project. You can press
B to open the browser on your local site.
If you’re using a framework, you can pass through the framework provided dev command (i.e. npm run dev) to run development and benefit from the framework hot-reloading and any special build process around it. You can do this with:
$ wrangler pages dev -- <command>
If you wish to attach a binding in your local development, you can simply pass through the relevant argument to the dev command. For example, if you want to bind KV, you would run:
$ wrangler pages dev <directory-of-assets> --kv KV
Then your KV binding will be accessible through
env.KV like usual. Read the section below for all the specific binding arguments.