Tailor

Docs

Tailor for React

Install

The SDK isn’t on npm yet: @tailor/react and @tailor/core ship as workspace packages in the repo.

git clone https://github.com/mlndshh/tailor && cd tailor
pnpm install && pnpm dev

Add the provider

// app/layout.tsx: read the last decision so the first render doesn't flicker
const initial = parseDecisionCookie((await cookies()).get("tailor_decision")?.value);
<TailorRoot initial={initial}>{children}</TailorRoot>   // a client wrapper around <TailorProvider>

Slot and Variant: re-render

One version at a time. rank=1 follows the second active audience. Swaps wait until the slot is off screen or the visitor navigates.

<Slot name="hero">
  <Variant default>…</Variant>
  <Variant audience="developer">…</Variant>
  <Variant audience="investor">…</Variant>
</Slot>

SlotGroup and Section: reorder

Every section always renders. Sections for active audiences move first; sections the visitor already reached stay put.

<SlotGroup name="home">
  <Section id="quickstart" title="Quickstart" audience="developer">…</Section>
  <Section id="pricing" title="Pricing" audience="growth_lead">…</Section>
</SlotGroup>

Emphasis and Signal

<Emphasis audience="growth_lead" onClassName="ring-2">…</Emphasis>
<Signal label="copied the install command"><CopyButton /></Signal>
const { decision, pin, track, reset } = useTailor();
API reference: POST /api/tailor/v1/decide
{ siteKey, sessionId, arrival: { referrer, utm_source, utm_campaign, utm_term, landingPath },
  events: RawEvent[], previous: Decision | null }
→ { decision: { primary, active, p, talkInterest, version },
    debug: { arrivalScores, actionScores, weight, latencyMs, tokens, costUsd, error } }

Latency and cost

Two small Jev requests: arrival once per session (cached across visitors with the same arrival) and actions after each meaningful click, debounced to one per 600 ms. Each has four or five yes/no questions; about 600 input tokens, roughly $0.00003 (estimated). A failed read keeps the current page.

Next step for youNew here? See how Tailor works