Client SDK Reference โ
The Client SDK is the public API surface of the Lantern web app โ every utility, service, hook, and constant exported from apps/web/src/lib/ and apps/web/src/hooks/. The admin portal renders an interactive listing of this surface at /client-sdk, generated from the source code's JSDoc comments.
Why it exists โ
- Discoverability โ one place to browse what the web app can do without grepping
lib/. - Single source of truth โ descriptions, signatures, and parameters live next to the code (JSDoc), not in hand-written docs that drift.
- Onboarding โ new contributors can scan categories like Venue Services or Authentication & Security before opening files.
Where it lives โ
| Surface | Path | Purpose |
|---|---|---|
| Source JSDoc | apps/web/src/lib/*.js, apps/web/src/hooks/*.js | The actual functions and their @param / @returns / @example blocks |
| Generator | tooling/scripts/generate-client-sdk-docs.mjs | Parses JSDoc โ categorizes โ emits HTML + JSON |
| Standalone HTML | tooling/client-sdk-static/index.html | Dark-themed reference, mirrored to apps/admin/public/client-sdk/ |
| React manifest | apps/admin/src/generated/client-sdk.json | Consumed by the admin's native React page |
| Admin page | apps/admin/src/components/ClientSdkPage.jsx | Renders the manifest at /client-sdk in the admin portal |
Pipeline โ
apps/web/src/lib/*.js โโdocumentation.jsโโโถ raw JSON
โ โ
โ โผ
โ dedupe + categorize
โ โ
โ โโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โ โผ โผ
โ tooling/client-sdk-static/ apps/admin/src/generated/
โ index.html client-sdk.json
โ โ
โ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโถ ClientSdkPage.jsx
(admin portal /client-sdk)documentation.js(npm package) walks the source files and emits a JSON AST of every exported symbol with its JSDoc.- The generator deduplicates re-exports (e.g.
devLogshows up wherever it's imported โ only the home file wins), categorizes each symbol, and renders descriptions to HTML. - Two outputs are written: a self-contained HTML reference (port
6007when served standalone) and a JSON manifest the admin React page consumes.
How files get categorized โ
Every .js file in apps/web/src/lib/ and apps/web/src/hooks/ must declare a category via an @sdkCategory tag in its top-level JSDoc block. There is no fallback โ if the tag is missing or names an unknown category, the build fails with an error pointing at the file.
/**
* @file Wave service โ meeting requests between users.
* @sdkCategory Social Features
*/To see all valid categories: npm run client-sdk:categories.
Available categories โ
Analytics, Authentication & Security, Dev & Testing Tools, Location & Proximity, Merchant & Offers, OpenStreetMap Integration, React Hooks, Social Features, User Profiles, Utilities, Venue Services. Adding a new one requires editing CATEGORY_ORDER, CATEGORY_ICONS, and CATEGORY_DESCRIPTIONS in the generator (keep CATEGORY_ORDER alphabetical).
Adding a new function or file โ
The TL;DR โ if you add any new exported function, hook, or constant under apps/web/src/lib/ or apps/web/src/hooks/, do this before committing:
- Document the export with JSDoc. At minimum a one-line summary; ideally
@param,@returns, and@exampleblocks. The generator reads these directly.js/** * Send a wave to another user at a venue. * @param {string} targetUserId * @param {string} venueId * @returns {Promise<void>} */ export async function sendWave(targetUserId, venueId) { /* ... */ } - If it's a brand-new file, add an
@sdkCategorytag to the top JSDoc block (see above). Skipping this fails the build immediately. - Regenerate with
npm run client-sdk:docs:build. - Commit the regenerated artifacts alongside your source change:
apps/admin/src/generated/client-sdk.jsonapps/admin/public/client-sdk/index.htmltooling/client-sdk-static/index.html
- Verify with
npm run client-sdk:docs:check(also runs as part ofnpm run validateand in CI).
If you forget step 3 or 4, npm run validate fails locally and CI blocks the PR. The error message tells you exactly which command to run.
When the listing is regenerated โ
The pipeline is enforced. The generated manifest is committed to git, and a freshness check runs in CI / npm run validate to fail if the committed files have drifted from the source JSDoc.
| Trigger | Behavior | Notes |
|---|---|---|
Editing JSDoc in apps/web/src/lib/*.js | โ ๏ธ Manual regeneration required | Run npm run client-sdk:docs:build and commit the updated client-sdk.json + HTML mirrors |
npm run validate (pre-commit) | โ Fails if stale | Runs client-sdk:docs:check โ regenerates in memory and compares against committed files |
| GitHub Actions CI | โ Fails if stale | Same check as validate. Also uploads a fresh build as a 7-day artifact |
npm run admin:build (production) | โ Regenerates | Always runs the generator before bundling โ production deploys are guaranteed fresh |
If the check fails, the CI/local error tells you exactly what to do: run npm run client-sdk:docs:build and commit the resulting files (apps/admin/src/generated/client-sdk.json, apps/admin/public/client-sdk/index.html, tooling/client-sdk-static/index.html).
Commands โ
# Regenerate the manifest + standalone HTML (no server)
npm run client-sdk:docs:build
# Regenerate AND serve the standalone HTML at http://localhost:6007
npm run client-sdk:docs
# Verify the committed manifest matches the source (used by CI / validate)
npm run client-sdk:docs:check
# List valid @sdkCategory values
npm run client-sdk:categoriesAfter running client-sdk:docs:build, commit the updated apps/admin/src/generated/client-sdk.json (and apps/admin/public/client-sdk/index.html).
Window dev utilities โ
The Window Dev Utilities category is manually curated โ it lists window.* functions exposed in apps/web/src/main.jsx (e.g. lantern.spoof.location.set(), lantern.dev.seedVenues()). These aren't ES exports, so JSDoc parsing won't find them. They live in the WINDOW_UTILITIES array at the top of the generator and must be edited by hand when adding new console-callable helpers.
See also โ
- The Storybook reference covers React components; the Client SDK covers non-component utilities, services, and hooks.
- API reference docs (Cloud Run services) live under
Admin โ API Reference, not here. - Source:
tooling/scripts/generate-client-sdk-docs.mjs