Next.js
The integration is <nlq-data> dropped into a server component. No 'use client' directive needed — the element hydrates on its own once elements.nlqdb.com/v1.js loads.
Run it
Section titled “Run it”npx create-next-app@latest nlqdb-orders --ts --app --no-tailwind --no-src-dircd nlqdb-ordersReplace app/page.tsx with the file in this folder, then:
echo "NEXT_PUBLIC_NLQDB_KEY=pk_live_yourkey" > .env.localnpm run dev'use client'is intentionally absent. Server components emit the markup; the browser-side runtime inelements.nlqdb.com/v1.jsupgrades the custom elements after hydration.next/scriptwithstrategy="afterInteractive"is the Next-idiomatic way to load a third-party module script after hydration. Don’t put a raw<script>in JSX — Next strips it during SSR.- The TypeScript declaration at the top of
page.tsxwill go away once@nlqdb/elementspublishes its own.d.ts(Phase 1). - For server-side calls (e.g. an RSC that pre-fetches data with a
sk_live_…), use@nlqdb/sdkfrom a route handler instead — coming with the SDK in Phase 1.
Live code
Section titled “Live code”Source on GitHub: examples/nextjs/.