11 · Docs / OpenAPI
Scalar — modern API reference UI
Use Scalar's beautiful API reference instead of Swagger UI. The html`` tagged template auto-escapes interpolation; raw() opts out.
Code
scalar.js
const { WebApp, html } = require(class="tk-str">39;@hyperbridge/forge/server39;); const app = new WebApp(); app.get(class="tk-str">39;/docs39;, (c) => c.html(htmlclass="tk-str">` <!DOCTYPE html> <html><head><title>API Reference</title></head> <body> <script id="api-reference" data-url="/openapi.json"></script> <script src="https:class="tk-cm">//cdn.jsdelivr.net/npm/@scalar/api-reference"></script> </body></html> `)); app.listen(3000);
How it works
Scalar renders OpenAPI specs as a polished, three-pane reference with built-in request tester.
The html`` tagged template is XSS-safe by default — any ${value} interpolation is HTML-escaped. Wrap with raw(value) to embed pre-trusted markup.
Same approach works for ReDoc, RapiDoc, Elements, or any HTML-driven viewer.
Try it
Quickstart
open http://localhost:3000/docs
Related modules
This is HBForge's port of Hono's example. Read the original at hono.dev/examples/scalar.