Documentation menu

Gyral documentation

Gyral builds web components from three pure parts. Intent turns platform events into typed messages, update turns messages into new state, and view turns state into HTML. Side effects such as HTTP, routing and timers are returned from update as data, and drivers carry them out at the edges of your app.

New here? Start with Getting started. It takes about ten minutes and ends with a working, tested component. Writing code with an agent? Connect it to Gyral's MCP server first: Use Gyral with coding agents.

The guides build on each other, but each one stands alone. The API reference is generated from the published type declarations, so it always matches the code.

Start here

  • Getting started

    Install Gyral, write your first Model-View-Intent component, use it in a page, and test it without a browser.

  • Recipes

    Complete components to copy, with their tests. A todo list with filters, a signup form with native validation, and fixes for common bugs.

  • Use Gyral with coding agents

    Connect Claude Code, VS Code or any MCP client to the Gyral MCP server, hosted or local, install the agent skill, and give agents llms-small.txt.

Guides

  • Components

    How define() turns a spec into a custom element, and how components pass data to each other with props and outputs.

  • Intent

    How Gyral turns clicks, input, form submissions and keys into typed messages, and why the view never holds event handlers.

  • Model and update

    State as plain data, one pure reducer per message, commands returned as data, and the framework messages Gyral sends you.

  • Views

    Views are pure functions from state to html templates. Name intents, render keyed lists, bind form state, and let the compiler check markup.

  • Styling and themes

    Style Gyral components with Shadow DOM, cascade layers, custom properties and custom states, and make a whole site themeable from CSS alone.

  • Forms

    A complete validated form to copy, then the browser's own checks or one Standard Schema for client and server. Works with or without JavaScript.

  • Custom form controls

    Make a Gyral component participate in native forms, with reset, disabled state, validity and a server-rendered fallback.

  • Effects and drivers

    Reducers return commands, side effects described as data. Drivers run them, with built-in concurrency, retries and cancellation, and answer with messages.

  • Error handling

    How Gyral reports each failure once, lets a parent catch a child's failure, shows a component's fallback and keeps a server-rendered page going.

  • Browser storage

    Typed localStorage and IndexedDB drivers: persist values, watch settings, query records and run atomic transactions.

  • Network streams

    Native EventSource and WebSocket drivers: receive validated streams, send messages and handle connection lifecycles.

  • Shared state

    Share state between distant components with stores, read like props from the side and written with messages, on the client and per request on the server.

  • State Gyral doesn't own

    Read signals, Redux-style stores, XState actors and WebSocket feeds with subscription(), write to them with plain drivers, and test both.

  • Routing

    Typed route tables that work on the server and in the browser, navigation as commands, and the current URL streamed into your model.

  • Rendering modes

    Choose how each page renders - in the browser only, once at build time, or on every request - and mix all three in one app.

  • Server rendering

    Render pages on the server with Declarative Shadow DOM, hydrate them in place, keep a strict CSP, and ship a production build.

  • Static sites and prerendering

    Render pages to HTML files at build time with @gyral/ssr/static, ship zero JavaScript where nothing is interactive, and host them anywhere.

  • Code-splitting and lazy loading

    Load each component's code only on the pages that use it, delay hydration until it's needed, and see what each page downloads.

  • Deploying

    Ship a Gyral app to a static host, a Node server, Bun, Deno or Cloudflare Workers, with the right cache headers and a strict Content Security Policy.

  • Rust servers

    Serve Gyral from a Rust backend with build-time pages, with Askama pages and browser-rendered components, or with embedded server rendering through gyral-rs.

  • Testing

    Test models without a DOM, components in a real browser with fake drivers and virtual time, and server-rendered pages through hydration.

  • Devtools

    Watch every message, state change and command in your app with an in-page panel that costs nothing in production builds.

  • Using Gyral in other frameworks

    Gyral components are standard custom elements. Use them in plain HTML, React, Vue or Svelte - set their props and listen to their outputs.

  • Using third-party web components

    Use Web Awesome, Shoelace, Material Web or any other custom element inside a Gyral view - turn its events into intents and style it through parts.

  • Security

    Escape template data, protect form requests, keep secrets out of hydration seeds, and serve Gyral with a strict Content Security Policy.

  • Accessibility

    Build Gyral views with native controls, useful labels, announced errors, predictable focus, and browser tests that cover keyboard interaction.

  • Performance

    Measure Gyral's production payload, rendering work and hydration cost, then use keyed rows, structural sharing and islands where they help.

Reference

  • Packages

    Every @gyral package, what it's for, how to install it, and the optional build tools Gyral works with.

  • API reference

    The public API of every Gyral package, generated from the type declarations at build time so it always matches the code.

  • Browser support

    Gyral targets Baseline widely available browser features, with explicit fallbacks and progressive enhancement for newer platform APIs.

  • Versioning and stability

    Understand Gyral's 0.x API policy, package versions, how to upgrade and which entry points are internal.

  • Error codes

    Every code a production build of Gyral prints, such as G0010: what the message says, what it means and how to fix it.

  • @gyral/core

    Gyral core: Model-View-Intent web components on the web platform, with their own view layer.

  • @gyral/http

    Gyral HTTP driver: fetch requests as data, typed errors, Standard Schema decoding.

  • @gyral/router

    Gyral router: typed route tables, navigation as commands, History API baseline with Navigation API enhancement.

  • @gyral/time

    Gyral time: delays, debounces and wall-clock ticks (every) as commands.

  • @gyral/ssr

    Gyral server rendering: Declarative Shadow DOM pages with hydration seeds.

  • @gyral/testing

    Gyral test helpers: pure update stepping, command helpers, fake drivers, virtual time, SSR page mounting, server rendering in Vitest browser tests.

  • @gyral/devtools

    Gyral devtools: an in-page timeline of messages, state, commands and stores (development builds).

Background

  • Coming from Cycle.js

    What Gyral keeps from Cycle.js, what it changes and why, the counter side by side, and how Cycle.js concepts map to Gyral.

  • Design principles

    The beliefs behind Gyral, from "the platform is the framework" to "parse at boundaries", and what each one means for your code.

  • Coming from Lit

    Move a Lit component to Gyral's Model-View-Intent loop: explicit props, pure views, typed messages, keyed rows, drivers, stores and native hydration.