HBForge/Examples
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.

forge/serverNodeBunDenoCF Workers
Code
scalar.js
const { WebApp, html } = require(class="tk-str">'@hyperbridge/forge/server');
const app = new WebApp();

app.get(class="tk-str">'/docs', (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