@adaptif/core
v0.1.0
Published
Config, types, and shared logic for Adaptif.
Maintainers
Readme
@adaptif/core
Shared pieces for every Adaptif package: the question config, the wire protocol, the timeline compiler, and the stability math. Zero runtime dependencies; runs in browsers, Node.js, and edge runtimes.
npm install @adaptif/coreMost apps use it for one thing: declaring their questions in adaptif.config.ts. React apps can skip installing it and import the same defineAdaptif from @adaptif/react/config.
import { defineAdaptif } from "@adaptif/core";
export interface AppState {
currentPage: string;
cart: string[];
}
export const adaptif = defineAdaptif<AppState>()({
situations: {
"The user seems to be weighing similar products rather than browsing past them": {
id: "comparingProducts",
uses: ["currentPage", "cart", "timeline"],
},
},
});That object is the server's allowlist (pass it to createHandler or createAdaptifRoute) and the source of the typed React API (createAdaptifReact). See Supply useful state.
The outcome types and @adaptif/core/outcome-schema.json are there if you're writing your own sink. Everything else is plumbing for the other packages and may change.
