A minimal example showing how to deploy a Hono web app on ArvanCloud Edge Computing.
This project demonstrates how to build and bundle a Hono app and run it in Arvan's edge function environment using the r1ec
CLI.
- ✅ Lightweight API using Hono (a super-fast edge framework)
- 🚀 Deployable on ArvanCloud Edge Compute
- 🔁 Portable to other edge platforms like Cloudflare Workers, Deno Deploy, Bun, etc.
git clone https://github.com/amirparsadd/r1ec-edge-hono.git
cd r1ec-edge-hono
npm install
The main logic lives in src/index.ts
:
import { Hono } from 'hono'
import { basicAuth } from 'hono/basic-auth'
import { cors } from 'hono/cors'
export const app = new Hono()
app.use(cors())
app.get('/', (c) => c.json({ message: 'Hello World' }))
app.get(
'/secret',
basicAuth({
username: 'admin',
password: 'admin',
}),
(c) => {
return c.text('This is a secret!')
}
)
// Make it compatible with R1Cloud Edge
export default {
async fetch(request: Request) {
return app.fetch(request)
}
}
npm run build
This will generate a bundled dist/index.js
using esbuild
, ready for edge deployment.
First, install and login to the CLI:
npm install -g r1ec
r1ec login -m YOUR_MACHINE_KEY
Then deploy:
r1ec deploy test -f dist/index.js
You'll receive a public edge URL in the panel.
curl https://test.amirparsab9.arvanedge.ir/
Response:
{ "message":"Hello World" }
r1c-edge-hono
├── src/
│ └── index.ts # Hono app source code
├── dist/
│ └── index.js # Bundled deployable output
├── package.json
├── README.md
└── LICENSE.md
ArvanCloud Edge expects a JavaScript file that exports a fetch(request)
handler. Hono supports this natively:
// Make it compatible with R1EC
export default {
async fetch(request: Request) {
return app.fetch(request)
}
}
This wrapper allows Arvan to treat the Hono app as an Edge Function.
MIT