Netlify
Use the hono/netlify adapter to wrap HttpRouter for Netlify Edge Functions.
1. Install
npm install @daiso-tech/core hono
2. Create the handler
// netlify/edge-functions/index.ts
import {
HttpRouter,
HttpRes,
defaultHttpRouterAdapter,
} from "@daiso-tech/core/http-router";
import { handle } from "hono/netlify";
const router = new HttpRouter({ router: defaultHttpRouterAdapter });
router.endpoint({
url: "/hello",
method: "GET",
handler: async () => HttpRes.text("Hello Netlify!"),
});
export default handle(router);
File structure
.
├── netlify
│ └── edge-functions
│ └── index.ts
├── package.json
└── netlify.toml
netlify.toml
[build]
command = "npm run build"
[[edge_functions]]
function = "index"
path = "/*"
3. Develop
netlify dev
4. Deploy
netlify deploy --prod
Reference: Hono on Netlify