Fastly Compute
Fastly's Compute offering allows us to build high scale, globally distributed applications and execute code at the edge of Fastly CDN.
Hono also works on Fastly Compute.
1. Install CLI
To use Fastly Compute, you must create a Fastly account if you don't already have one. Then, install Fastly CLI.
macOS
brew install fastly/tap/fastlybrew install fastly/tap/fastlyFollow this link for other OS:
2. Setup
A starter for Fastly Compute is available. Start your project with "create-hono" command.
txt
npm create hono@latest my-appnpm create hono@latest my-apptxt
yarn create hono my-appyarn create hono my-apptxt
pnpm create hono my-apppnpm create hono my-apptxt
bunx create-hono my-appbunx create-hono my-apptxt
deno run -A npm:create-hono my-appdeno run -A npm:create-hono my-appMove to my-app and install the dependencies.
txt
cd my-app
npm icd my-app
npm itxt
cd my-app
yarncd my-app
yarntxt
cd my-app
pnpm icd my-app
pnpm itxt
cd my-app
bun icd my-app
bun i3. Hello World
Edit src/index.ts:
ts
// src/index.ts
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Fastly!'))
app.fire()// src/index.ts
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Fastly!'))
app.fire()4. Run
Run the development server locally. Then, access http://localhost:7676 in your Web browser.
txt
npm run devnpm run devtxt
yarn devyarn devtxt
pnpm devpnpm devtxt
bun run devbun run dev4. Deploy
txt
npm run deploynpm run deploytxt
yarn deployyarn deploytxt
pnpm deploypnpm deploytxt
bun run deploybun run deployThat's all!!
Hono