Skip to content

About 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.

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.

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
Define your schema once, generate forms, validation, migrations, and CRUD operations automatically. Single source of truth eliminates inconsistencies. Compile-time type checking ensures your forms match your schema exactly. Catch errors before runtime. Schema definitions are computed once at initialization. Identical query performance to manual implementations. React Hook Form patterns, Zod-like validation, and Drizzle-style schemas. Developers from web backgrounds feel right at home. Reduce boilerplate by 90%+. One schema definition replaces hundreds of lines of manual code. Build forms in minutes, not hours. Focus on business logic, not infrastructure code.

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.

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.

React Hook Form developers will recognize:

// React Hook Form
const { register, handleSubmit, errors } = useForm()
// ZyraForm
@StateObject var form = PowerSyncForm<UserFormValues>(schema: UsersSchema)
form.handleSubmit { values in ... }
form.errors["email"]

Zod users will recognize:

// Zod
z.string().email().min(3).max(50)
// ZyraForm
.text("email").email().minLength(3).maxLength(50)

Drizzle ORM users will recognize:

// Drizzle
pgTable("users", {
email: text().notNull(),
name: text().notNull()
})
// ZyraForm
ExtendedTable(
name: "users",
columns: [
.text("email").notNull(),
.text("name").notNull()
]
)

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)

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.

βœ… πŸ›‘οΈ 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

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)

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

ZyraForm is built on three powerful components that work together. Learn more about each component β†’

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)

Ready to experience the ZyraForm difference?


πŸŽ‰ Start building faster, better forms with ZyraForm today.