React
A Vite + React 19 single-page app using the typed @nlqdb/react wrapper. This is the solo-builder’s alternative to the Next.js example: no SSR, no router — just npm create vite@latest, drop in App.tsx, ship.
Run it
Section titled “Run it”npm create vite@latest nlqdb-meals -- --template react-tscd nlqdb-mealsnpm install @nlqdb/react @nlqdb/elementsNot on npm yet —
@nlqdb/reactand@nlqdb/elementsare built onmainbut unpublished (docs/progress.md §0), so the install above 404s today. Until they publish, run this example inside the monorepo (bun installlinks the workspace packages) or use the CDN<nlq-data>element per the HTML example.
Replace src/App.tsx with the file in this folder, then:
echo "VITE_NLQDB_KEY=pk_live_yourkey" > .envnpm run dev<NlqScript />injectshttps://elements.nlqdb.com/v1.jsonce. It deduplicates across re-renders and across multiple<NlqData />siblings.- Typed props. The wrapper’s
goal/apiKey/template/refreshare camelCase and TS-checked; the underlying custom element keeps its kebab-case attributes. TheonLoadhandler gets a typedNlqDataLoadDetail. - SPA-only. This sample is client-rendered; for App Router / RSC, see
examples/nextjs/. - Action element (
<NlqAction />) is the write side of the wrapper; we omit it here to keep the read-only sample focused. See the@nlqdb/reactREADME for the full surface.
Live code
Section titled “Live code”Source on GitHub: examples/react/.