About ZyraForm
π What is ZyraForm?
Section titled βπ What is ZyraForm?βZyraForm is a Swift package that extends the PowerSync Swift Package for offline-first functionality. It provides syntax similar to Zod for validation, Drizzle ORM for schema definitions, and React Hook Form for form management. It eliminates the need for repetitive boilerplate code while maintaining zero runtime overhead and providing end-to-end type safety.
π The Problem ZyraForm Solves
Section titled βπ The Problem ZyraForm SolvesβTraditional Swift form development requires:
- β Manual schema definitions (PowerSync tables)
- β Separate validation logic (custom validators)
- β Manual field configuration (TableFieldConfig arrays)
- β Custom form state management (ObservableObject boilerplate)
- β Manual CRUD implementations (one service per table)
- β Manual encryption handling (encrypt/decrypt calls everywhere)
- β Duplicate type definitions (schema β form values β models)
π± Result: 500+ lines of boilerplate code per table, prone to errors, and difficult to maintain.
β¨ The ZyraForm Solution
Section titled ββ¨ The ZyraForm SolutionβWith ZyraForm, you define your schema once:
let UsersSchema = ExtendedTable( name: "\(AppConfig.dbPrefix)users", columns: [ .text("email").email().notNull(), .text("name").minLength(2).maxLength(50).notNull(), .text("age").int().positive().intMin(18).intMax(120) ])π― Everything else is automatic:
- β Form validation
- β Error handling
- β Type inference
- β CRUD operations
- β Encryption handling
- β Swift model generation
- β Drizzle schema generation
- β SQL migration generation
π¨ Features
Section titled βπ¨ Featuresβπ Code Comparison
Section titled βπ Code ComparisonβSee Core Concepts β for detailed before/after comparisons showing how ZyraForm reduces boilerplate code by eliminating repetitive patterns across schema definitions, validation logic, form state management, and CRUD operations.
β‘ Performance
Section titled ββ‘ Performanceβπ Zero Runtime Overhead
Section titled βπ Zero Runtime OverheadβZyraForm has zero performance impact on database queries:
- β Schema computed once at initialization (~0.1ms one-time cost)
- β Query execution identical to manual PowerSync implementations
- β Builder methods inlined by Swift compiler
- β No runtime reflection - all metadata is explicit
Performance Characteristics:
- Schema initialization: ~0.1ms one-time cost per table
- Query execution: Identical to manual PowerSync implementations
- Memory overhead: ~200-500 bytes per table definition (negligible)
The metadata is static data computed once at app startup. At query time, ZyraForm uses the same native PowerSync.Table instances as manual implementations, resulting in identical performance.
Developer Experience π¨βπ»
Section titled βDeveloper Experience π¨βπ»βFamiliar Syntax π
Section titled βFamiliar Syntax πβReact Hook Form developers will recognize:
// React Hook Formconst { register, handleSubmit, errors } = useForm()
// ZyraForm@StateObject var form = PowerSyncForm<UserFormValues>(schema: UsersSchema)form.handleSubmit { values in ... }form.errors["email"]Zod users will recognize:
// Zodz.string().email().min(3).max(50)
// ZyraForm.text("email").email().minLength(3).maxLength(50)Drizzle ORM users will recognize:
// DrizzlepgTable("users", { email: text().notNull(), name: text().notNull()})
// ZyraFormExtendedTable( name: "users", columns: [ .text("email").notNull(), .text("name").notNull() ])Faster Development Times β±οΈ
Section titled βFaster Development Times β±οΈβTraditional Approach:
- Define schema: 15 minutes
- Create service class: 30 minutes
- Build form view: 45 minutes
- Add validation: 20 minutes
- Test and debug: 30 minutes
- π΄ Total: ~2.5 hours per form
With ZyraForm:
- Define schema: 5 minutes
- Create form view: 10 minutes
- Test: 5 minutes
- π Total: ~20 minutes per form
π Result: Estimated 87% faster development (based on typical form complexity)
πͺ Less Syntax, More Power
Section titled βπͺ Less Syntax, More PowerβZyraForm eliminates repetitive code patterns:
- Validation: Define once in schema, used automatically in forms and services
- CRUD Operations: One generic service replaces hundreds of lines of per-table code
- Type Safety: Schema-driven type inference eliminates manual type conversions
- Code Generation: SQL migrations, Drizzle schemas, and Swift models generated automatically
See Core Concepts β for detailed comparisons showing how ZyraForm reduces boilerplate.
π’ Enterprise Ready
Section titled βπ’ Enterprise Readyββ
π‘οΈ Type Safety: Compile-time checked schemas and forms
β
π Backward Compatible: Works with existing PowerSync code
β
π Thread Safe: Immutable structs, no retain cycles
β
πΎ Memory Safe: No leaks, proper error handling
β
β
Production Ready: Built on proven PowerSync patterns
β
β‘ Zero Runtime Cost: Query execution identical to manual implementations
π Impact Metrics
Section titled βπ Impact MetricsβBased on typical form development patterns:
- π 90%+ code reduction per table (estimated from code comparisons)
- β‘ Significantly faster development time (estimated 70-90% faster for typical forms)
- π― Zero runtime overhead for query execution (identical performance to manual implementations)
- π‘οΈ Compile-time type safety with Swiftβs type system
- π 1 schema definition replaces 5+ files (PowerSync table, config, validation, models, migrations)
π¬ Why Developers Choose ZyraForm
Section titled βπ¬ Why Developers Choose ZyraFormβDevelopers benefit from ZyraForm because:
- Schema-first approach eliminates the need to maintain separate validation logic
- Familiar patterns from React Hook Form and Zod make it easy to learn
- Zero runtime overhead means you get all the benefits without performance trade-offs
- Type safety catches errors at compile-time, reducing bugs
- Rapid development lets you focus on business logic instead of boilerplate
π§© Understanding the Core Components
Section titled βπ§© Understanding the Core ComponentsβZyraForm is built on three powerful components that work together. Learn more about each component β
Built With β€οΈ
Section titled βBuilt With β€οΈβZyraForm integrates seamlessly with these powerful technologies:
- PowerSync - Offline-first database synchronization
- Zod - TypeScript-first schema validation (inspiration for validation API)
- Drizzle ORM - TypeScript ORM (schema generation compatible)
- React Hook Form - Form state management patterns (API inspiration)
π Get Started
Section titled βπ Get StartedβReady to experience the ZyraForm difference?
- π§© Core Concepts - Understand the architecture
- π¦ Installation - Set up in minutes
- β‘ Quick Start - Build your first form
- π Schema Definition - Learn the API
π Start building faster, better forms with ZyraForm today.