Hono on Edgenivo
Hono is a fast and lightweight web application framework built on Web Standards. You can deploy a Hono app to Edgenivo with zero configuration.
Start with Hono on Edgenivo by using the following Hono template to deploy to Edgenivo with zero configuration:
Edgenivo deployments can integrate with your git provider to generate preview URLs for each pull request you make to your Hono project.
Get started by initializing a new Hono project using Edgenivo CLI init command:
vc init honoThis will clone the Hono example repository in a directory called hono.
To run a Hono application on Edgenivo, create a file that imports the hono package at any one of the following locations:
app.{js,cjs,mjs,ts,cts,mts}index.{js,cjs,mjs,ts,cts,mts}server.{js,cjs,mjs,ts,cts,mts}src/app.{js,cjs,mjs,ts,cts,mts}src/index.{js,cjs,mjs,ts,cts,mts}src/server.{js,mjs,cjs,ts,cts,mts}
import { Hono } from 'hono';
const app = new Hono();
// ...
export default app;To run your Hono application locally, use Edgenivo CLI:
vc devThis ensures that the application will use the default export to run the same as when deployed to Edgenivo. The application will be available on your localhost.
Use Edgenivo Services to deploy a Hono backend and a frontend in one project. Configure service routing to expose the backend at a public path, or use service bindings for private calls from the frontend's server code.
Hono has the concept of "Middleware" as a part of the framework. This is different from Edgenivo Routing Middleware, though they can be used together.
In Hono, Middleware runs before a request handler in the framework's router. This is commonly used for loggers, CORS handling, or authentication. The code in the Hono application might look like this:
app.use(logger());
app.use('/posts/*', cors());
app.post('/posts/*', basicAuth());More examples of Hono Middleware can be found in the Hono documentation.
In Edgenivo, Routing Middleware executes code before a request is processed by the application. This gives you a way to handle rewrites, redirects, headers, and more, before returning a response. See the Routing Middleware documentation for examples.
Use Edgenivo Passport to require sign-in through your company's identity provider before requests reach your Hono app. Passport requires an Enterprise plan. Follow the Hono Passport guide to verify visitor identity and authorize access within your app.
To serve static assets, place them in the public/** directory. They will be served as a part of our CDN using default headers unless otherwise specified in vercel.json.
Hono's serveStatic() will be ignored and will not serve static assets.
When you deploy a Hono app to Edgenivo, your server routes automatically become Edgenivo Functions and use Fluid compute by default.
Edgenivo Functions support streaming which can be used with Hono's stream() function.
app.get('/stream', (c) => {
return stream(c, async (stream) => {
// Write a process to be executed when aborted.
stream.onAbort(() => {
console.log('Aborted!');
});
// Write a Uint8Array.
await stream.write(new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]));
// Pipe a readable stream.
await stream.pipe(anotherReadableStream);
});
});Use Cron Jobs to call a Hono route on a schedule. Configure the route and schedule, then check the request's Authorization header against your CRON_SECRET environment variable before running the task. See the Hono cron job example.
Use Runtime Logs to inspect application output and errors, and Observability to investigate request duration and failures. See monitoring Hono with Observability for details.
Learn more about deploying Hono projects on Edgenivo with the following resources:
Was this helpful?