Get started
A Fieldia page is a JSON document. You show it with the viewer, or with the binding for your framework, and you give it a data source that loads and saves records.
Install
Pick the package for your framework. Each one brings the core, the fields and the viewer with it.
npm install @fieldia/viewer # plain JavaScript
npm install @fieldia/react # React 18 or 19
npm install @fieldia/vue # Vue 3
npm install @fieldia/angular # Angular 21 or 22
Tables of lines that should edit like a spreadsheet add @fieldia/grid — see the grid; code in any of 44 languages adds @fieldia/code, or @fieldia/monaco for VS Code's editor — see the code editors; a place or an area on a map, a list's records on one, or a map of a record's places, its live courier and its route, adds @fieldia/map — see maps; a list's records on a calendar add @fieldia/calendar, and as bars on a Gantt timeline @fieldia/gantt — see on a calendar and on a timeline; a record's conversation and to-dos beside it add @fieldia/chatter — see the chatter.
No bundler? Load the script bundle instead — it sets the global Fieldia. See a script tag below.
A first page
A page names its fields once, then lays them out. This one collects sign-ups, so its data is responses rather than a record:
{
"fieldia": "0.13",
"id": "signup",
"title": "Workshop sign-up",
"data": { "kind": "responses" },
"fields": {
"name": { "type": "char", "label": "Full name", "required": true },
"email": { "type": "char", "label": "Email", "required": true },
"role": {
"type": "selection", "label": "Your role",
"options": [
{ "value": "developer", "label": "Developer" },
{ "value": "other", "label": "Something else" }
]
},
"other_role": { "type": "char", "label": "Which role?" }
},
"layout": {
"type": "sections", "id": "sections",
"children": [{
"type": "section", "id": "you", "columns": 2,
"children": [
{ "type": "field", "id": "name", "field": "name" },
{ "type": "field", "id": "email", "field": "email" },
{ "type": "field", "id": "role", "field": "role", "widget": "radio" },
{ "type": "field", "id": "other_role", "field": "other_role",
"invisible": "role != 'other'", "required": true }
]
}]
}
}
Which role? shows only when someone picks Something else, and it is required only then. The page format describes every part.
Plain JavaScript
import { mountViewer } from '@fieldia/viewer';
import { createMemoryDataSource } from '@fieldia/core';
import page from './signup.page.json';
const viewer = mountViewer(document.getElementById('app'), {
page,
dataSource: createMemoryDataSource(),
skin: 'outlined',
});
mountViewer returns a handle: viewer.form is the live form (values, errors, setValue, subscribe), and viewer.destroy() removes it.
React
import { FieldiaForm } from '@fieldia/react';
export function Signup() {
return <FieldiaForm page={page} dataSource={dataSource} skin="outlined" />;
}
Vue
<script setup lang="ts">
import { FieldiaForm } from '@fieldia/vue';
</script>
<template>
<FieldiaForm :page="page" :data-source="dataSource" skin="outlined" />
</template>
Angular
import { Component } from '@angular/core';
import { FieldiaFormComponent } from '@fieldia/angular';
@Component({
selector: 'app-signup',
imports: [FieldiaFormComponent],
template: `<fieldia-form [page]="page" [dataSource]="dataSource" skin="outlined" />`,
})
export class SignupComponent {
readonly page = page;
readonly dataSource = dataSource;
}
A script tag
For a page with no build step at all. The bundle holds what runs a form — the core, the fields and the viewer — in 197 KB gzipped, with its own words in English. Its larger parts — a list's screen, lines, files, a survey's steps, the themes and 49 more — are scripts of their own beside it, which it fetches the first time a page uses one. It checks a page with Fieldia.checkPage before it draws it, and with the whole check, validatePage's verdict, after the first draw — a script of its own, fieldia.check.js; the full validatePage is in @fieldia/core, for where pages are made.
Each tag names a version — 0.36.1, the latest — and carries the hash of its file (integrity, with crossorigin="anonymous"): the browser runs that file and no other, so a page takes no release until you move it to one, and never a copy changed on the way. Copy the tags as they are here. To move to a newer release, take every tag from that release's README (on npm, its version's page), fieldia.js and the scripts beside it alike. The parts fieldia.js fetches are checked the same way: it carries the hash of each one it was built with, and a part that is not that file is refused — what needed it says it could not be loaded. Served from your own site instead, the scripts keep their folder together; from another origin than the page's, that origin sends Access-Control-Allow-Origin, as a CDN does.
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/@fieldia/viewer@0.36.1/bundle/fieldia.js"
integrity="sha256-dQgaaTAAs7rFub4PEFyNjjl4qIKeFCJapyCYxHKR81U="
crossorigin="anonymous"></script>
<script>
fetch('/signup.page.json')
.then((response) => response.json())
.then((page) => Fieldia.mountViewer(document.getElementById('app'), {
page,
dataSource: Fieldia.createMemoryDataSource(),
}));
</script>
Arabic, German and French come as small scripts of their own, 19 to 24 KB gzipped each, and so do Turkish, Persian, Urdu and Spanish (fieldia.tr.js, fieldia.fa.js, fieldia.ur.js, fieldia.es.js) — machine-assisted, not yet reviewed by a native speaker: add the language's script after the main one, from the same version, with its own integrity (every language's tag is below), and pass locale. The words only a part shows come with that part, in English, and the language's script has them all, whichever comes first. A page whose language script is missing shows Fieldia's words in English and names the script to add in the console. Installed from npm, the packages have English with no extra import, and fetch every other language each in a chunk of its own where it is spoken: the viewer waits for them before it draws, so a page's first paint is in its language.
<script src="https://cdn.jsdelivr.net/npm/@fieldia/viewer@0.36.1/bundle/fieldia.js"
integrity="sha256-dQgaaTAAs7rFub4PEFyNjjl4qIKeFCJapyCYxHKR81U="
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@fieldia/viewer@0.36.1/bundle/fieldia.ar.js"
integrity="sha256-rlD91cBhhDrJlWu24RLCtdeujbWFyRGFZoIPUuZz7gY="
crossorigin="anonymous"></script>
<script>
Fieldia.mountViewer(document.getElementById('app'), { page, dataSource, locale: 'ar' });
</script>
One tag: <fieldia-form>
The script defines an element as it starts, so a page needs no code of its own: <fieldia-form> fetches its page (src), draws its form in itself and sends the answers to its action as JSON — { pageId, values, … }, answered with { id }, or refused with { message, fields }. locale, theme, skin, record and resume say the rest; changing one draws it again (a theme or a skin in place). What it does comes in a part of its own, fetched the first time one is on a page: until then the element is a stub, made what it is in place as it comes. action takes a page of responses' answers; a record's page saves through your own source.
<script src="https://cdn.jsdelivr.net/npm/@fieldia/viewer@0.36.1/bundle/fieldia.js"
integrity="sha256-dQgaaTAAs7rFub4PEFyNjjl4qIKeFCJapyCYxHKR81U="
crossorigin="anonymous"></script>
<fieldia-form src="/forms/enquiry.page.json" action="/api/enquiries" locale="ar" skin="outlined"></fieldia-form>
It tells what happens as events that bubble: fieldia-ready once drawn, fieldia-send (the reference your server gave, and the answers), fieldia-save, fieldia-step and fieldia-error when its page, or its part, cannot be had. With a little code, its properties take the rest of the viewer: page (given whole), source (your own data source, for a record's page, codes, payments) and options — set before its part came, they are kept; handle is the viewer once drawn. An app built with a bundler calls defineFieldiaForm() from @fieldia/viewer once.
const form = document.querySelector('fieldia-form');
form.source = myDataSource; // sendCode, checkCode, pay, submit… your app's own
form.addEventListener('fieldia-send', (event) => analytics.track('enquiry', { id: event.detail.id }));
On another site: an iframe that grows with its form
For a form your app serves on a site that is not yours — a partner's, a WordPress page, a broker's listing — one script tag places an iframe of your form's page where it stands: fieldia-embed.js, 0.9 KB gzipped, with nothing else of Fieldia's in it. Your page holds <fieldia-form frame>, which tells the page round it its height as it changes — the frame grows and shrinks with the form, never a scrollbar inside — and what happens: fieldia-ready, fieldia-step and fieldia-send (its reference, never the answers) as events on the iframe, from your page's origin only.
<!-- On the partner's page -->
<script src="https://cdn.jsdelivr.net/npm/@fieldia/viewer@0.36.1/bundle/fieldia-embed.js"
integrity="sha256-ExxESXxAGtdBEClR3ORbtRrsYUVPtidColiX28O95ZY="
crossorigin="anonymous"
data-src="https://forms.example.com/enquiry" data-locale="ar" data-theme="material" async></script>
<!-- Your form's page, https://forms.example.com/enquiry -->
<script src="https://cdn.jsdelivr.net/npm/@fieldia/viewer@0.36.1/bundle/fieldia.js"
integrity="sha256-dQgaaTAAs7rFub4PEFyNjjl4qIKeFCJapyCYxHKR81U="
crossorigin="anonymous"></script>
<fieldia-form src="/forms/enquiry.page.json" action="/api/enquiries" frame
allowed-origins="https://partner.example"></fieldia-form>
Your form tells its height and what happened to the sites its allowed-origins names (spaces between them), and to your own: a page of another site that frames it is told nothing — not even its height — and the console says so. "*" tells any site that frames it, which you choose by writing it; it is never so by default. To keep other sites from framing it at all, send Content-Security-Policy: frame-ancestors https://partner.example with your form's page.
data-locale, data-theme and data-skin reach the form through its frame's address; data-title names the frame for a screen reader; data-height is its height before the form tells its own (600). The partner page's campaign parameters — utm_source, utm_medium, utm_campaign, utm_term, utm_content, or those data-params names — are passed on, so a page that fills hidden fields from its link (prefill) knows which campaign brought the person to the partner. The embed demo shows both.
Under a strict Content-Security-Policy
A bank's, a government's or an enterprise's site often runs under a policy with no 'unsafe-inline' and no 'unsafe-eval'. Fieldia works under it: nothing it runs is code made from text, nothing it draws writes a style attribute (what is worked out as it is drawn — a width, a colour — is set through the element's style object, which a policy lets be), and every <style> it adds — its own sheet, each part's as it comes, the calendar's, the chatter's, a map's, the designer's, CodeMirror's and AG Grid's — carries your page's nonce. Give it as nonce, the nonce your server wrote into this response's policy:
// Content-Security-Policy: script-src 'nonce-r4nd0m'; style-src 'nonce-r4nd0m'; img-src 'self' data: blob:
mountViewer(element, { page, dataSource, nonce: 'r4nd0m' }); // <FieldiaForm nonce="…">, :nonce, [nonce] alike
mountScreenEditor(element, { designer, nonce: 'r4nd0m' }); // and the survey editor
Left out, Fieldia takes the page's <meta property="csp-nonce" nonce="…">, as Vite writes it, and the one-tag script takes its own tag's: give <script nonce="…" src="…/fieldia.js"> the nonce and it carries it to every part's tag it adds and every sheet. A formatted text keeps its own looks — a line centred, a word's colour, highlight and size — in its value as style attributes, the HTML you store and e-mail; Fieldia never has the browser read one as HTML (a policy would refuse it), and puts each on through the element's style object, so the text looks the same under the policy as without it. Pictures and files shown in place need img-src data: blob: (and frame-src blob: for a PDF's preview). Two add-ons bring code of their own that a policy may refuse: VS Code's editor (@fieldia/monaco) adds sheets Monaco makes with no nonce — under a strict policy use @fieldia/code, which carries it — and a map draws Leaflet and your map provider's tiles, which img-src must allow.
See it working: a sign-up, a customer, an order and every field under a strict policy, and the one-tag script under it — each says what the policy refused: nothing. fieldia.dev is a static site with no server of its own, so there the policy is a meta tag in the page and its nonce was written once, when the site was built, the same for every visitor. Your server does what a static site cannot: it sends the policy as a header and makes a new nonce for every response — a nonce that never changes is one an attacker can read and reuse.
On a server: Next and Nuxt
A site whose pages a server renders shows the form before any script has run. firstPaint(page, { values }), from @fieldia/viewer/server, draws the form's first paint as plain HTML — its title, its sections, each field's label and its box with its value — in Fieldia's look, the page's own rules run (what is hidden, read-only, worked out), in Node with no DOM. The viewer then mounts over it: the live form is drawn out of sight and takes the first paint's place in one step once it is drawn and its record in — never a blank — and what a person typed in the first paint meanwhile is carried over, the caret where it was. In React and Vue, the component does it given firstPaint, on the server as Next and Nuxt render it, and hydrates it as it is:
<FieldiaForm page={page} dataSource={dataSource} recordId={record.id} firstPaint={{ values: record }} /> // Next
<FieldiaForm :page="page" :data-source="dataSource" :record-id="record.id" :first-paint="{ values: record }" /> // Nuxt
// Any other server: the HTML into the element the viewer is mounted in.
const html = `<div id="app">${firstPaint(page, { values: record })}</div>`;
It is a first paint, not the whole form rendered on the server: what needs a script — a date's calendar, a choice's own list, a table of lines' tools, a map — comes with the live form. The first paint holds no style attribute, so under a strict policy it needs only the nonce.
A server that knows the page can also write the tags of the parts it draws from into the HTML, before fieldia.js and from the same folder, so they come beside it rather than once it has run — measured on a mid-range phone, a list of customers usable 23% sooner on 4G and 27% on Fast 3G, a record with tabs 16% on both. partFiles(page), from @fieldia/viewer/server, names them (a page given createMemoryDataSource adds fieldia.memory.js); fieldia.js takes a part whose tag it finds on its way and never asks for it twice. A tag the page writes is the page's own script, checked by the integrity it carries: write exactly what Fieldia.partTags(page) gives — each part's address, crossorigin="anonymous" and integrity, the sha256 of its file, the one value fieldia.js checks that part by — on a <script async> tag and on a <link rel="preload" as="script"> alike, which the browser uses only for a request made the same way. A list's first page of records is asked for as its part is, not once it has come.
import { partFiles } from '@fieldia/viewer/server';
// integrity: each file's sha256, as Fieldia.partTags(page) gives it.
const parts = partFiles(page).map((file) => `<script async src="${base}${file}" integrity="${integrity[file]}" crossorigin="anonymous"></script>`).join('');
// …then fieldia.js's own tag, from the same folder (base).
Testing your forms
@fieldia/testing tests the forms in your app as people use them: a field found by the words of its label, typed in and left, picked from, ticked; a button pressed by its words; then what a person sees read back — a field's problems, what its box shows. The same helpers for Testing Library (any DOM, under Jest or Vitest) and for Playwright:
import { fieldia } from '@fieldia/testing'; // Testing Library, jsdom, a browser
// import { fieldia } from '@fieldia/testing/playwright'; // Playwright: fieldia(page)
const form = fieldia(host);
await form.fill('Email', 'mona@');
expect(form.errorsOf('Email')).toEqual(['Enter an email address, like name@example.com']);
await form.fill('Email', 'mona@example.com');
await form.pick('Country', 'Egypt');
await form.check('I agree to the terms');
await form.press('Submit');
expect(form.valueOf('Email')).toBe('mona@example.com');
Each step sends the events a person's would — a key at a time, so a box that refuses a letter refuses it in your test too — and leaves the box, where Fieldia says a problem. And one line of CI keeps the pages your app stores valid after an upgrade: npx fieldia-check pages/ checks each as Fieldia reads it, says what is wrong with each, and fails the build when one is refused. See the package's README for every helper.
How fast, measured
Measured on each release on a desktop and on a mid-range phone profile (412 px, a CPU four times slower), in Chromium, as medians; the counts — parts brought up to date, rows and elements in the page, cells written, bytes — are held by CI's perf job against budgets that fail the build.
- Typing keeps up at 500 fields on a desktop. A key works out only what reads the field typed in: on a page of 500 fields it brings 16 of its parts up to date and reads no condition again, in 3.9–6.9 ms on a desktop — under the 16 ms of a frame. Not yet on a mid-range phone on the biggest page: 17–21 ms on a 500-field form, up to 36 ms on the 500-field example page, most of it the browser's paint.
- Lists stay flat to 5,000 rows. Past 100 rows a list keeps only the rows near the view in the page — 5,000 rows hold about 1,600 DOM nodes, over 100,000 before 0.35 — and a tick, a Tab, a reload or a fold costs about the same at 5,000 rows as at 100. A table of 200 lines draws again only the lines a change touches.
- Small from npm. An app's first load from the packages, bundled by esbuild: a record form 240.0 KB gzipped with the page and 330 KB to usable, a list 239.2 and 325, the screen designer 586 and 813 (
tools/npm-first-load.mjs, a CI budget). The one-tagfieldia.jsis 197 KB gzipped; its larger parts come as a page first uses them.
Next
The memory data source keeps everything in the browser — right for trying things, not for keeping them. Data sources shows how to connect your own backend; Fields lists every field type and how it can be shown.
Moving to a newer Fieldia? The changelog says what changed in each release, in plain words, with what to change in your app under Upgrading; pages your app keeps are brought up to date as they are read (versions).