Documentation

Guides, references, and machine-readable specs for developers and AI agents.

Raw .md
Build custom React, Next.js, Vue, or Svelte UIs with @blokforms/react and @blokforms/client./docs/sdk.md

React & Headless SDK

BlokForms publishes three ESM + TypeScript npm packages under the @blokforms scope:

  • @blokforms/react — <BlokForm /> component and useBlokForm() React hook (React 18 & 19)
  • @blokforms/client — framework-agnostic headless controller (createFormController)
  • @blokforms/core — shared types, validator, logic engine, VAT calculator, and appointment slot math

Install

bash
npm install @blokforms/react
# Or for Vue, Svelte, Angular, or vanilla TypeScript:
npm install @blokforms/client

Quick Start with <BlokForm />

tsx
import { BlokForm } from "@blokforms/react";

export function LeadCaptureForm() {
  return (
    <BlokForm
      formId="frm_YOUR_FORM_ID"
      baseUrl="https://cdn.blokforms.com"
      locale="en"
      onSuccess={(payload) => {
        console.log("Submission ID:", payload.submissionId);
        if (payload.booking?.icsUrl) {
          console.log("Calendar invite:", payload.booking.icsUrl);
        }
      }}
      onError={(error, fieldErrors) => {
        console.error(error, fieldErrors);
      }}
    />
  );
}

Custom UI Overrides (components prop)

Replace field wrappers, submit buttons, or success screens with your own Tailwind or design system components while keeping validation, uploads, appointments, and password gates handled automatically:

tsx
<BlokForm
  formId="frm_YOUR_FORM_ID"
  baseUrl="https://cdn.blokforms.com"
  components={{
    FieldWrapper: ({ field, error, children }) => (
      <div className="space-y-1.5">
        <label className="text-sm font-medium">{field.label}</label>
        {children}
        {error ? <p className="text-xs text-red-600">{error}</p> : null}
      </div>
    ),
    SubmitButton: ({ label, submitting }) => (
      <button type="submit" disabled={submitting} className="btn-primary">
        {submitting ? "Sending..." : label}
      </button>
    ),
  }}
/>

Headless Hook (useBlokForm)

tsx
import { useBlokForm } from "@blokforms/react";

export function CustomBookingForm() {
  const { controller, state } = useBlokForm({
    formId: "frm_YOUR_FORM_ID",
    baseUrl: "https://cdn.blokforms.com",
  });

  if (state.isLocked) {
    return (
      <button type="button" onClick={() => void controller.unlock("my-password")}>
        Unlock form
      </button>
    );
  }

  return (
    <form
      onSubmit={(e) => {
        e.preventDefault();
        void controller.submit();
      }}
    >
      <input
        type="email"
        value={String(state.values.email ?? "")}
        onChange={(e) => controller.setValue("email", e.target.value)}
      />
      {state.fieldErrors.email ? <span>{state.fieldErrors.email}</span> : null}
      <button type="submit">Send</button>
    </form>
  );
}

Framework-Agnostic Controller (@blokforms/client)

ts
import { createFormController } from "@blokforms/client";

const ctrl = createFormController({
  formId: "frm_YOUR_FORM_ID",
  baseUrl: "https://cdn.blokforms.com",
});

ctrl.subscribe(() => {
  const s = ctrl.getState();
  console.log(s.status, s.visibleFields.length, s.fieldErrors);
});

await ctrl.load();
await ctrl.fetchAppointmentSlots("appointment_slot", "2026-12-10");
ctrl.setValue("email", "ada@example.eu");
await ctrl.submit();