Svelte
A Vite + Svelte 5 single-page app using the typed @nlqdb/svelte wrapper. This is the first-timer’s entry point — Svelte’s small mental model + nlqdb’s “type what you want” prompt means a student can see real rows in under a minute.
Run it
Section titled “Run it”npm create vite@latest nlqdb-first-db -- --template svelte-tscd nlqdb-first-dbnpm install @nlqdb/svelte @nlqdb/elementsNot on npm yet —
@nlqdb/svelteand@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.svelte with the file in this folder, then:
echo "VITE_NLQDB_KEY=pk_live_yourkey" > .envnpm run dev- Svelte 5 runes. This sample uses the modern lowercase-callback convention (
onload=instead ofon:load=). The wrapper supports both. - Apostrophe-free goal.
"all users, newest first"reads naturally and stays under nlqdb’s “one-clause, one-result” sweet spot. - No
<svelte:head>needed — the wrapper injectselements.nlqdb.com/v1.jsthe first time<NlqData />mounts. - For SvelteKit (with SSR +
+server.tsSDK calls), seeexamples/sveltekit/.
Live code
Section titled “Live code”Source on GitHub: examples/svelte/.