API reference

Every public export of Silgi has a section in this reference, with its signature and a short example. The examples are real files in landing/samples/api/ that the repository's check compiles, so they match the code.

PageImport fromWhat it holds
silgisilgidefineConfig and the config types
silgi/appsilgi/appcode that runs in pages: loaders, middleware, errors, state, head, $fetch, app plugins
silgi/serversilgi/servercode that runs on the server: handlers, request and response utilities, sessions, storage, cache, WebSockets
silgi/kitsilgi/kitthe module author's tools
silgi/adaptersilgi/adapter, silgi/adapter/devwhat an adapter implements, and its dev-only helpers
@silgi/<library>@silgi/react, @silgi/vue, @silgi/preact, @silgi/solid, @silgi/svelte, @silgi/htmlthe hooks and components of each adapter, one section per name
@silgi/i18n@silgi/i18nthe i18n module, its options and useApp().i18n
@silgi/db@silgi/db, @silgi/db/server, @silgi/db/clithe db module, its connections, migrations, useDatabase and runDbCommand

A name that two entry points export, such as $fetch and createError, is documented on both pages and is the same function.

How the pages are written

  • A function has one section with its signature and an example.
  • Types that belong to a function are grouped in one section after it, with a table of their fields.
  • src/ directories and internal modules, such as the files in silgi's src/runtime/, are not public and are not listed.

The script scripts/check-api-docs.ts runs in bun run check as check:api-docs. It reads the export statements of each entry point's index file and fails, naming the export, when a page has no heading that contains that name in backticks. It also reads the exports of every package and fails when an entry such as silgi/kit has no heading naming it.