Local development with Cloudflare Pages template
mainTo set up and run the Cloudflare Pages starter template locally, use the following commands:
- Install dependencies:
npm install - Start the development server:
npm run dev
npm install
npm run devrepository·main·Indexed 41 days ago
https://github.com/honojs/starterA collection of pre-configured starter templates for Hono, providing environments for various runtimes and platforms including Bun, Cloudflare Workers, Cloudflare Pages, AWS Lambda, AWS Lambda@Edge, Node.js, Deno, Fastly, Vercel, and Next.js. Includes instructions for scaffolding projects via `create-hono` and platform-specific deployment and development guides.
To set up and run the Cloudflare Pages starter template locally, use the following commands:
npm installnpm run devnpm install
npm run devTo perform a local build of the project to verify the production build process, run:
npm install
vc buildTo get started with the Node.js template, install the dependencies and start the development server using your preferred package manager. Once running, the application is accessible at http://localhost:3000.
npm install
npm run devTo run the Fastly template on your local machine for development, use the following commands:
npm installnpm run starthttp://localhost:7676npm install
npm run start
# Open http://localhost:7676To deploy your Hono application to the Vercel platform, use the Vercel CLI (vc) to trigger a deployment after installing dependencies:
npm install
vc deployTo deploy your application to Cloudflare Pages, run the deploy script:
npm run deployTo get type safety for your Fastly resources (like KV Stores or Config Stores), use buildFire from @fastly/hono-fastly-compute instead of the standard fire.
buildFire with an object mapping your desired resource names to their Fastly types (e.g., 'KVStore' or 'ConfigStore:name').fire.Bindings as the generic parameter to the Hono constructor to enable typed access to these resources within your routes.import { buildFire } from '@fastly/hono-fastly-compute'
// Define your resources
const fire = buildFire({
assets: 'KVStore', // A KV Store named 'assets'
mySettings: 'ConfigStore:my-settings' // A Config Store named 'my-settings'
})
// Pass fire.Bindings as the generic parameter
const app = new Hono<{ Bindings: fire.Bindings }>()To start a local development server for this Hono template, ensure you have the Vercel CLI installed globally. Run the following commands to install dependencies and start the development environment:
npm installvc devhttp://localhost:3000npm install
vc devTo set up and deploy a Hono application using the Lambda@Edge template, use npm to install dependencies and run the deployment command. This template is designed to run your Hono application at the edge using AWS Lambda@Edge.
npm install
npm run deployTo generate or synchronize TypeScript types based on your specific Cloudflare Worker configuration (such as environment variables and bindings), run the cf-typegen script. This ensures your local development environment is aware of the bindings available in your production environment.
npm run cf-typegenTo start the development server for the Cloudflare Workers template, use the following commands:
npm installnpm run devnpm install
npm run devTo start the local development environment for the Cloudflare Workers + Vite template, use the dev script. This typically starts the Vite development server to provide hot module replacement (HMR) and local testing.
npm run dev