Readme

Example Hono app with a Fiberplane API explorer.

For an example with OpenApiHono, see: https://www.val.town/v/fiberplane/fiberplaneHonoOpenApiStarter

  1. Import @fiberplane/hono
import { createFiberplane, createOpenAPISpec } from "https://esm.sh/@fiberplane/hono@0.4.3-valtown.1";
  1. Generate a simplified API spec (if you don't already have one)
app.get("/openapi.json", async (c) => { const spec = createOpenAPISpec(app, { info: { title: "My Hono API", version: "1.0.0" }, }); return c.json(spec); });
  1. Mount the api explorer
import { createFiberplane, createOpenAPISpec } from "https://esm.sh/@fiberplane/hono@0.4.3-valtown.1"; import { Hono } from "https://esm.sh/hono@4.7.0"; const app = new Hono(); // ... Define your api routes here! app.use( "/*", createFiberplane({ openapi: { url: "/openapi.json" }, }), ); export default app.fetch;
  1. Visit your Val's root route to play with the API explorer!

How it Works

createFiberplane mounts a UI at the root route (/), which can be used to explore the api's routes and make requests. Think of it like an embedded, lightweigh postman.

If you don't have an API spec at the ready, then the createOpenAPISpec utility helps create a simple OpenAPI spec from all routes in the application. (Note that this simple spec does not include information on expected query parameters, headers, or payloads!)

Code
HTTP
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
fiberplane-fiberplanehonostarter.web.val.run
Updated: February 24, 2025