Choosing an adapter
Where your feedback lives — Prisma for production, memory for tests and demos, localStorage for client-only setups.
An adapter is the storage layer behind SitePing. All three implement the same SitepingStore contract (6 methods), so you can swap them without touching the widget.
| Adapter | Where data lives | Use it for |
|---|---|---|
@siteping/adapter-prisma | Your database, via Prisma | Production — the standard setup |
@siteping/adapter-memory | An in-process array | Tests, previews, throwaway demos |
@siteping/adapter-localstorage | The visitor's browser | Client-side demos and prototypes — no server at all |
Two ways to mount a store
Server mode — the widget talks to an HTTP endpoint, and the endpoint talks to the store. This is the production shape:
// app/api/siteping/route.ts
import { createSitepingHandler } from "@siteping/adapter-prisma";
import { prisma } from "@/lib/prisma";
export const { GET, POST, PATCH, DELETE, OPTIONS } = createSitepingHandler({ prisma });Client-side mode — the widget writes to a store directly in the browser, no server needed:
import { initSiteping } from "@siteping/widget";
import { LocalStorageStore } from "@siteping/adapter-localstorage";
initSiteping({ store: new LocalStorageStore(), projectName: "my-demo" });Writing your own adapter? Implement the 6
SitepingStoremethods and run the shared conformance suite —testSitepingStore(factory)from@siteping/core/testing(40 tests) — against it.