duckweb_client_shell

scalar · LOAD duckweb

duckweb_client_shell(VARCHAR) -> VARCHAR

A complete HTML response that boots the app in the browser.

SELECT duckweb_client_shell(
  '{"start":"/",'
  || '"extensions":["/_duckweb/httpfs.duckdb_extension.wasm","/_duckweb/duckweb.duckdb_extension.wasm"],'
  || '"app":"/_duckweb/app.duckdb"}')
FROM duckweb_match(route, '/client') WHERE method = 'GET'

Returns the whole response — a skeleton page that loads DuckDB-Wasm, attaches the app database, and renders subsequent navigations locally with the same render macro the server runs. Do not put a head before it or a duckweb_end after it.

config is JSON the bootstrap reads: start (the first route to render), extensions (wasm extensions to load), app (the database to attach) and setup (statements to run after attaching). Pass '' for the default — one extension, one database, starting at /.

The root element carries hidden until the stylesheet and the first content have arrived, so a reader never sees an unstyled or half-built page.

In the browser tiers this answers 501: a page already running the client has no need to serve itself another copy, and those bytes would come out of the wasm size budget for nothing.