Choosing an adapter
Where your feedback lives — Prisma or SQLite for production, memory for tests and demos, localStorage for client-only setups.
An adapter is the storage layer behind InstaFix. All of them implement the same InstaFixStore contract (6 methods), so you can swap them without touching the widget.
| Adapter | Where data lives | Use it for |
|---|---|---|
@instafix/adapter-prisma | Your database, via Prisma | Production — already on Prisma |
@instafix/adapter-sqlite | A local .db file, via better-sqlite3 | Production — no ORM or database server needed |
@instafix/adapter-memory | An in-process array | Tests, previews, throwaway demos |
@instafix/adapter-localstorage | The visitor's browser | Client-side demos and prototypes — no server at all |
Not sure which one? If the project already has Prisma set up, use it — otherwise SQLite gets you a real, durable store with nothing else to install or run. npx github:gnoopy/instafix#cli-dist init asks and wires up whichever you pick.
Need a different backend entirely (Postgres without Prisma, MongoDB, DynamoDB, …)? Write your own with @instafix/adapter-kit.
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/instafix/route.ts
import { createInstaFixHandler } from "@instafix/adapter-prisma";
import { prisma } from "@/lib/prisma";
export const { GET, POST, PATCH, DELETE, OPTIONS } = createInstaFixHandler({ prisma });Client-side mode — the widget writes to a store directly in the browser, no server needed:
import { initInstaFix } from "@instafix/widget";
import { LocalStorageStore } from "@instafix/adapter-localstorage";
initInstaFix({ store: new LocalStorageStore(), projectName: "my-demo" });Writing your own adapter? Install
@instafix/adapter-kit: snapshot backends get a complete store fromcreateCollectionStore, query backends implement the 6 methods, and both verify with the shared conformance suite (44 tests). See Writing an adapter.