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.

AdapterWhere data livesUse it for
@siteping/adapter-prismaYour database, via PrismaProduction — the standard setup
@siteping/adapter-memoryAn in-process arrayTests, previews, throwaway demos
@siteping/adapter-localstorageThe visitor's browserClient-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 SitepingStore methods and run the shared conformance suite — testSitepingStore(factory) from @siteping/core/testing (40 tests) — against it.

Edit on GitHub

On this page