Introduction

What protokit is, what problems it solves, and how it fits into a Nuxt 4 project.

Introduction

protokit is a Nuxt 4 module for rapid product prototyping. It turns a plain TypeScript schema into a fully working interactive prototype — forms, CRUD lists, computed values, visualizations, and automatic offline persistence — so you can validate ideas and ship working demos without spending time on boilerplate.

The problem it solves

Building interactive prototypes by hand is repetitive:

  • Every calculator or configurator needs the same form wiring, computed watchers, and storage layer
  • Every CRUD list needs the same add/edit/delete/search/sort boilerplate
  • Every time a prototype needs to share data with another, you wire up custom state management
  • Changing a field type means touching the template, the store, and the TypeScript types simultaneously

protokit removes this repetition. The schema is the single source of truth. The same object that describes which fields a prototype has also drives its form rendering, computed values, result display, visualizations, and IndexedDB key — all at once.

When to use it

protokit is designed for rapid product prototyping. If you need to go from idea to working, data-persistent interface fast — without spending time on form wiring, storage, or CRUD boilerplate — it's a good fit:

  • Product configurators and pricing tools — cost models, pricing calculators, ROI estimators with live computed results
  • Internal dashboards and trackers — CRUD-driven views with search, sort, and structured data entry (task trackers, item registries, pipeline boards)
  • Assessment and evaluation prototypes — scoring rubrics, weighted questionnaires, comparison matrices
  • Connected prototype suites — multiple screens sharing computed data through a reactive data graph

It is not designed for:

  • General-purpose form libraries with arbitrary validation logic — use Vee-Validate or Formkit
  • Production database-backed admin panels — use a headless CMS or Nuxt UI Pro data tables
  • Real-time collaborative text editors — Y.js is the foundation, but you would be working at a lower level

Auto-imported API surface

After adding the module to nuxt.config.ts, the following are available globally without any import statement:

Utils

NameDescription
definePrototypeType-safe schema definition helper (identity function for inference)
defineCollectionType-safe collection schema helper
formatMoneyFormat a number as currency
formatPercentFormat a number as a percentage
formatNumberFormat a number with locale-aware separators
formatDateFormat an ISO date string for display

Composables

NameDescription
usePrototypeHigh-level facade — fields, derived, collections, reset, isReady
useProtoDocY.js document lifecycle — IndexedDB, BroadcastChannel, server sync
useProtoMapBidirectional Y.Map ↔ reactive refs sync
useProtoListLow-level Y.Array CRUD
useProtoCollectionHigh-level CRUD with search, sort, and item count
useProtoDerivedReactive derived value computation from a schema and context
useProtoOutputsCross-prototype produces/consumes wiring via shared Y.Maps
useProtoDraftDraft persistence for modal item editors
useProtoCorruptionCorruption event queue and recovery flow
useProtoRegistryGlobal schema registry — register and look up schemas by key
useProtoKitConfigRead the module's runtime config (serverSync enabled, baseUrl)

Components (globally registered)

NameDescription
ProtoToolFull prototype renderer — form, results, viz, collections, actions
ProtoFormForm fields only, driven by schema fields or sections
ProtoCrudListCRUD list or table for a single collection
ProtoCrudModalModal item editor with automatic draft persistence
ProtoStatGridStat card grid from results.stats
ProtoVizSingle visualization renderer
ProtoActionBarCopy / export / reset action toolbar
ProtoDebugPanelDev-only Y.js state inspector
ProtoCorruptionModalNon-dismissible corruption recovery modal

All field components (ProtoFieldText, ProtoFieldNumber, ProtoFieldSelect, …) and visualization components (VizProgressBar, VizBarChart, …) are also globally registered for custom layout use.

Server sync backend

protokit handles the client side of persistence only. Cross-device sync and server-backed corruption recovery require a backend that implements the Y.js sync API endpoints (POST /api/yjs/sync, GET /api/yjs/pull, GET /api/yjs/snapshots/:key). You can use the separate yjs-sync companion module or implement the endpoints yourself.

Client (protokit)                      Server (yjs-sync)
─────────────────                      ─────────────────
useProtoDoc                        ──► POST /api/yjs/sync
  ├─ IndexedDB persistence              └─ Stores binary updates in D1/SQLite
  ├─ BroadcastChannel tab sync     ──► POST /api/yjs/snapshots/create
  └─ 30s debounced server push          └─ Deduplicated JSON snapshots
                                   ◄── GET  /api/yjs/pull
                                   ◄── GET  /api/yjs/snapshots/{key}

The server module is required for cross-device sync and the full corruption recovery flow. Without it, prototypes still persist locally via IndexedDB — the corruption modal simply will not offer a "restore from server backup" option.

Server sync is controlled via the protokit.serverSync config key. See Server Sync →.

Need a Landing Page?

Modern landing pages with optional modules (blog, docs, forms, i18n). Let's discuss your project.

Build Your MVP

Full-stack SaaS development. Expert in database design, multi-tenancy, and scalable architecture.

Deployment Help

Dockerize your backend, set up CI/CD pipelines, deploy to Cloudflare or Hetzner. Early-stage setup.

Suggest a SaaS Tool

Missing a calculator or tool? Suggest what you'd like to see on our site.