Skip to content

Start here

Getting started

By the end of this page you will have a form built visually, rendered in your framework, and validated on your server — all from the same file. It takes one install and about twenty lines of code.

Pick the package matching your app. The framework wrappers pull in the Web Components and the core transitively.

Terminal window
npm install @streamline-pulse/formkrafter-react

The builder produces a spec; the renderer consumes it. Wiring the two together is the whole integration:

  1. Mount the builder and keep the spec it emits. Every edit fires specChange with the new spec — plus the RFC 6902 patches that produced it, if you want undo/redo or an audit trail.

  2. Feed that spec to the renderer. It is plain JSON: store it, version it, fetch it back later.

  3. Import the stylesheet once. It is opt-in and about 6 KB — skip it and style the .fk-* classes yourself if you prefer.

FormStudio.tsx
import { useState } from 'react'
import { FkFormBuilder, FkFormRender } from '@streamline-pulse/formkrafter-react'
import '@streamline-pulse/formkrafter-wc/styles.css'
import type { BrickSpec } from '@streamline-pulse/formkrafter-core'
export function FormStudio() {
const [spec, setSpec] = useState<BrickSpec>()
return (
<>
<FkFormBuilder onSpecChange={(e) => setSpec(e.detail.spec)} />
{spec && (
<FkFormRender
spec={spec}
onFormSubmit={(e) => console.log(e.detail.data)}
/>
)}
</>
)
}

The browser verdict is a convenience for your users; the server verdict is the one that counts. Both come from the same spec:

server/submit.ts
import { validateFormData } from '@streamline-pulse/formkrafter-core'
import type { BrickSpec } from '@streamline-pulse/formkrafter-core'
export async function submit(spec: BrickSpec, payload: unknown) {
const { valid, errors } = validateFormData(spec, payload, 'en')
if (!valid) {
// { fullName: 'This field is required', 'contacts[0].email': 'Invalid email' }
return { status: 422, errors }
}
return { status: 200, data: payload }
}

A project by Streamline Pulse