@cfpreview/pages-cli

[Private Beta Preview] Pages CLI

Usage no npm install needed!

<script type="module">
  import cfpreviewPagesCli from 'https://cdn.skypack.dev/@cfpreview/pages-cli';
</script>

README

[Beta] Pages CLI

$ npm install @cfpreview/pages-cli
$ pages dev [directory | -- command]

Examples

Create React App

$ pages dev --proxy 3000 -- npx react-scripts start

A static folder

$ pages dev ./public

Options

Name Description Default
--port The port to listen on. 7000
--proxy The port to proxy requests for env.ASSETS.fetch to. Automatically determined by inspecting command process.
--config The path to the beta configuration file. ./pages-functions-beta.json

Miniflare

Inside your pages-functions-beta.json file, you can add a "miniflare" object which is passed into the constructor of Miniflare:

{
  "entryPoint": "./functions",
  "baseURL": "/",
  "miniflare": {
    "kvPersist": true,
    "kvNamespaces": ["MyKVNamespace"]
  }
}

You can use this to enable environment variables and secret bindings, custom build commands for single Worker setups, KV, and Durable Objects.

Note: this is only for local development and has no impact on any production settings.

Roadmap

  • Improve help message (the -- command option presents weirdly)
  • Auto-configure --proxy based on command run
    • Testing on Windows
  • Bindings
  • Custom build scripts for single Worker setups