Skip to content
Myr

docs: write instructions (#125)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent 4dd0ede · Browse files · 1 file+30 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+30 added−18 removed

  • other:+30 added−18 removed

1 file+30 added−18 removed

modified:README.md+30 added-18 removed
379 unmodified lines
380```381382## Cloudflare Workers with Hono383384Using `wrangler` or `miniflare`, you can develop the application locally and publish it with few commands.384Using [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/) or [Miniflare](https://miniflare.dev), you can develop the application locally and publish it with few commands.385386Let's write your first code for Cloudflare Workers with Hono.387388### 1. Install Wrangler388---389390Install Cloudflare Command Line "[Wrangler](https://github.com/cloudflare/wrangler)".390### Caution391392```sh393$ npm i @cloudflare/wrangler -g394```392**Wrangler 1.x** does not support importing middleware. We recommend two ways:393396### 2. `npm init`3941. Use [Wragler 2.0 Beta](https://github.com/cloudflare/wrangler2).3952. Build without webpack 4.x. For example, you can use esbuild. See [the starter template](https://github.com/yusukebe/hono-minimal).396397---398399### 1. `npm init`400401Make a npm skeleton directory.402403```sh404mkdir hono-example405cd hono-example406npm init -y407```408406### 3. `wrangler init`409### 2. `wrangler init`410408Init as a wrangler project.411Initialize as a wrangler project.412410```sh411$ wrangler init413```414$ npx wrangler@beta init415```416414### 4. `npm install hono`417Answer the questions. If you want, you can answer `y`.418419```420Would you like to install wrangler into your package.json? (y/n) <--- n421Would you like to use TypeScript? (y/n) <--- n422Would you like to create a Worker at src/index.js? (y/n) <--- n423```424425### 3. `npm install hono`426427Install `hono` from the npm registry.428429```sh430$ npm i hono431```432422### 5. Write your app433### 4. Write your app434435Only 4 lines!!436437```js438// index.js439import { Hono } from 'hono'440const app = new Hono()441442app.get('/', (c) => c.text('Hello! Hono!'))443444app.fire()445```446435### 6. Run447### 5. Run448449Run the development server locally. Then, access `http://127.0.0.1:8787/` in your Web browser.450451```sh440$ wrangler dev452$ npx wrangler@beta dev index.js453```454443### 7. Publish455### 6. Publish456457Deploy to Cloudflare. That's all!458459```sh448$ wrangler publish460$ npx wrangler@beta publish index.js461```462463## Starter template464453You can start making your application of Cloudflare Workers with [the starter template](https://github.com/yusukebe/hono-minimal). It is a realy minimal using TypeScript, esbuild, and Miniflare.465You can start making your application of Cloudflare Workers with [the starter template](https://github.com/yusukebe/hono-minimal). It is really minimal using TypeScript, esbuild, and Miniflare.466467To generate a project skelton, run this command.468469```
38 unmodified lines