# Ynch documentation # How it works > What happens between your files and the app on your iPhone, and why it is safe. ```text your computer Ynch Studio your iPhone ------------- ----------- ----------- .ynch files -- upload --> draft you approve --> signed you activate --> active --> Ynch app opens it ``` ## An app is data, not code A Ynch app is a set of JSON files that describe screens, navigation, a theme and, if you use a database, the exact reads and writes the app may make. There is no JavaScript, CSS or SQL in it, and nothing in it is ever executed. The Ynch app on your phone reads the description and draws it with native controls. Because the vocabulary is fixed, `ynch check` can tell you precisely whether an app is valid before anything leaves your computer. ## Nothing is live until you say so An upload is only a draft. In Studio you approve one exact draft, and Studio signs it. Making a signed version active is a separate step. You can keep several signed versions and switch which one is active. ## Your phone checks what it opens The Ynch app downloads the active version and verifies its signature before showing anything. A version that was changed after you approved it does not open. ## Your database stays behind Studio If your app uses a database: - The app's files hold no passwords, keys or addresses, only the name of a connection. - You enter the connection details once, in Studio, where they are kept in a secrets vault. - The app declares each read and write it needs as an **operation**: which table, which columns, which filters. You approve each one in Studio. - Your phone never talks to the database. It asks Studio to run an approved operation, and Studio runs exactly that. An app cannot run a query you did not approve, and a changed operation needs approving again. ## Next - [Project layout](https://docs.ynch.ai/guides/project-layout.md) - [Releases and versions](https://docs.ynch.ai/guides/releases.md) --- # Quick start > From an empty folder to an app open on your iPhone. You need Node.js 22 or later, a Ynch Studio account, and the Ynch app on your iPhone, signed in to the same account. ## 1. Install the CLI In a new, empty folder: ```sh npm init -y npm install --save-dev @ynch/cli@beta ``` ## 2. Connect the folder to Studio ```sh npx ynch connect ``` The CLI prints a Studio link. Open it, sign in and choose **Approve CLI connection**. Back in the terminal, pick one of your projects or create a new one. The CLI then writes a starter app into a `.ynch` folder. > **Note:** The connection lasts as long as your Studio session. If an upload later says there is no active connection, run `npx ynch forget --draft` and then `npx ynch connect` again. ## 3. Change something Open `.ynch/screens/home.json` and change the welcome text, or ask your coding agent to build what you have in mind. [Working with coding agents](https://docs.ynch.ai/guides/coding-agents.md) has a prompt to start from. ## 4. Check it ```sh npx ynch check ``` `check` reads your files and reports anything that is wrong, with the file and the place. It changes nothing and uses no network. ## 5. Upload a draft ```sh npx ynch upload ``` This builds the app and uploads it to your project as a draft. Nothing is live yet. ## 6. Approve it in Studio In Studio, open your project and go to **Releases**. The checklist walks you through it: 1. **Approve & sign** the draft. Studio signs that exact version. 2. **Make it active**. Your iPhone opens the active version. 3. **Accept database changes**, only if the app uses a database and asks for something new. ## 7. Open it on your iPhone Open the Ynch app. Your project appears in the list; tap it, then choose **Open App in Ynch**. Pull down on the list to refresh after you make a new version active. ## Next - [Build your first app](https://docs.ynch.ai/tutorials/first-app.md): two screens and a button between them. - [Project layout](https://docs.ynch.ai/guides/project-layout.md): what each file is for. --- # What is Ynch? > What Ynch does, who it is for and what you can build with it. Ynch puts an app you described onto a real iPhone, usually within minutes. You (or your coding agent) write the app as a small folder of JSON files. Ynch checks it, you approve it in Ynch Studio, and it opens on your iPhone inside the Ynch app, drawn with native iPhone controls. It is for trying an idea on a real device before deciding whether to build it as a full App Store app. You need no Mac, no Xcode, no Apple developer account and no App Store submission. ## The three parts | Part | What it does | | --- | --- | | **Ynch CLI** | Runs on your computer. Creates the project, checks it and uploads a draft. | | **Ynch Studio** | The website at `studio.ynch.ai`. You review each upload, sign it, choose which version is live, and manage your database connection. | | **Ynch for iPhone** | The app on your phone. It opens the version you made live and draws it natively. | ## What an app can do today - Screens built from [18 native components](https://docs.ynch.ai/reference/components.md): text, images, buttons, cards, lists, forms and inputs. - Navigation between screens, with an optional [tab bar](https://docs.ynch.ai/tutorials/tab-bar.md). - Your own colors, spacing and type through a [theme](https://docs.ynch.ai/guides/theme.md). - Read and write your own data in [Supabase or MySQL](https://docs.ynch.ai/tutorials/connect-a-database.md), with every kind of access approved by you. - [Sign-in for your app's own users](https://docs.ynch.ai/tutorials/app-sign-in.md) with Supabase accounts. - [Notifications](https://docs.ynch.ai/tutorials/notifications.md) to your phone from your own server. ## What it is not Ynch apps run inside the Ynch app; they are not separate apps on the home screen or in the App Store. There is no custom code: an app is made only from the components and options in these docs. That limit is what lets a new version reach your phone in minutes, and it is why a coding agent can write one reliably. Ynch is iPhone only today, and Studio is open by invitation. ## Next [Quick start](https://docs.ynch.ai/get-started/quick-start.md) takes you from an empty folder to an app on your phone. --- # Add app sign-in > Let your app's own users sign in with Supabase accounts, so each one sees their own rows. App sign-in is for the people who use your app, with the accounts in **your** Supabase project. It is separate from your Ynch account. It needs a [Supabase connection](https://docs.ynch.ai/tutorials/connect-a-database.md). ## 1. Declare it In `.ynch/connections.json`, add `userAuth` and name the field that holds the user's id on your tables: ```json { "schemaVersion": "1.0.0", "connections": { "primary": { "cloudConnectionId": "conn_main", "provider": "supabase", "userAuth": { "userColumn": "user-id" } } } } ``` `user-id` here means the database column `user_id`. ## 2. Use the column in your models and operations For a table that holds per-user rows, include the user field in the model and in the operation's `columns`. For example, a `progress` table with `user_id`: - When the app **reads**, Studio adds a filter so a user only gets rows where `user_id` is their own id. - When the app **inserts**, Studio fills `user_id` with the signed-in user's id. The app cannot set it to someone else's. Requests also carry the user's own Supabase session, so your row level security policies (for example `auth.uid() = user_id`) apply as they would in any Supabase app. ## 3. Upload and accept Upload, approve and activate as usual. Studio then shows **Database settings have changed**: accepting turns app sign-in on and approves the operations in one step. ## What users see When the app needs a signed-in user, it shows a sign-in screen with email and password. The session is kept in the iPhone's Keychain and renewed automatically. The app's detail screen in Ynch has a sign-out row. ## Limits today - Supabase only. - Email and password sign-in for existing accounts. Sign-up and password reset happen in your own Supabase flows. --- # Connect a database > Show rows from your own Supabase or MySQL database in a list. Your app can read and write your own data. This tutorial shows a list of rows from a Supabase table. MySQL works the same way with different connection details. How it stays safe is described in [How it works](https://docs.ynch.ai/get-started/how-it-works.md#your-database-stays-behind-studio): the app holds no credentials, and it can only run the reads and writes you approve. ## 1. Connect the database in Studio Open your project in Studio and go to **Database**. Choose **Supabase** and enter: - a connection name, - your project URL, - your **anon** (publishable) key. Never the service role key: with the anon key, your row level security rules stay in charge. Studio tests the connection before saving it. ## 2. Name the connection in the app `.ynch/connections.json` names the connection the app uses. It holds no address and no key: ```json { "schemaVersion": "1.0.0", "connections": { "primary": { "cloudConnectionId": "conn_main", "provider": "supabase" } } } ``` ## 3. Describe a row with a model Say the table is `topics` with `id`, `name` and `description`. Create `.ynch/models/topic.json`: ```json { "schemaVersion": "1.0.0", "id": "topic", "identityField": "id", "fields": { "id": { "type": "string", "required": true, "minLength": 36, "maxLength": 36 }, "name": { "type": "string", "required": true, "maxLength": 120 }, "description": { "type": "string", "required": false, "maxLength": 500 } } } ``` > **Note:** Names in Ynch files use hyphens. A hyphen maps to an underscore in the database, so the field `display-order` reads the column `display_order`. ## 4. Declare the read as an operation Create `.ynch/operations/list-topics.json`: ```json { "schemaVersion": "1.0.0", "id": "list-topics", "kind": "list", "connection": "primary", "connector": "supabase", "resource": "topics", "columns": ["id", "name", "description"], "responseModel": "topic", "parameters": {}, "filters": [], "sort": [{ "field": "name", "direction": "asc" }, { "field": "id", "direction": "asc" }], "maxRows": 50, "pagination": { "mode": "offset", "defaultLimit": 25, "maxOffset": 10000 } } ``` This is the whole of what the app may do with that table: read those three columns, sorted by name, up to 50 rows at a time. A list's sort always ends with the identity field so paging is stable. ## 5. Show the rows In a screen, add a `RecordList`. Its one child is drawn once per row, and components inside it can show the row's fields: ```json { "id": "topic-list", "type": "RecordList", "props": { "pageSize": 25, "emptyText": "No topics yet" }, "bindings": { "items": { "operationId": "list-topics", "parameters": {}, "pagination": { "offset": 0, "limit": 25 } } }, "children": [ { "id": "topic-item", "type": "Card", "props": {}, "preset": "panel", "children": [ { "id": "topic-name", "type": "Text", "props": {}, "bindings": { "value": { "model": "topic", "field": "name" } } }, { "id": "topic-description", "type": "Text", "props": {}, "bindings": { "value": { "model": "topic", "field": "description" } } } ] } ] } ``` ## 6. Upload, activate, then accept ```sh npx ynch check npx ynch upload ``` In Studio, follow the Releases checklist: approve and sign, make it active, then **Accept database changes**. Studio shows each operation in plain words ("Read a list of rows from topics") before you accept. Open the app on your iPhone. The list loads from your database. ## Next - [Models and operations](https://docs.ynch.ai/guides/data.md): filters, parameters, and writing data. - [App sign-in](https://docs.ynch.ai/tutorials/app-sign-in.md): show each user only their own rows. --- # Build your first app > A two-screen app with a button that goes from one to the other. You will build a home screen and an about screen, and a button that goes from one to the other. Finish the [quick start](https://docs.ynch.ai/get-started/quick-start.md) first so you have a connected `.ynch` folder. ## 1. Look at the home screen `.ynch/screens/home.json` is the screen the starter created: ```json { "schemaVersion": "1.0.0", "id": "home", "root": { "id": "home-root", "type": "Screen", "props": { "title": "Home", "safeArea": true, "scroll": true }, "preset": "page", "children": [ { "id": "welcome", "type": "Text", "props": { "text": "Welcome to Ynch" }, "preset": "heading" } ] } } ``` Every screen file has one `Screen` at its root, and the screen's `id` matches the file name. ## 2. Add a second screen Create `.ynch/screens/about.json`: ```json { "schemaVersion": "1.0.0", "id": "about", "root": { "id": "about-root", "type": "Screen", "props": { "title": "About", "safeArea": true, "scroll": true }, "preset": "page", "children": [ { "id": "about-title", "type": "Text", "props": { "text": "About this app" }, "preset": "heading" }, { "id": "about-card", "type": "Card", "props": {}, "preset": "panel", "children": [ { "id": "about-text", "type": "Text", "props": { "text": "Built with Ynch in an afternoon." } } ] } ] } } ``` ## 3. Give it a route A screen can only be reached through a route. In `.ynch/navigation.json`, add one to `routes`: ```json { "id": "about", "screenId": "about", "label": "About", "parameters": {} } ``` ## 4. Add a button on the home screen Add this to the `children` of the home screen, after the welcome text: ```json { "id": "open-about", "type": "Button", "props": { "label": "About this app" }, "action": { "type": "navigate", "routeId": "about", "parameters": {} } } ``` ## 5. Check and upload ```sh npx ynch check npx ynch upload ``` Approve and activate the draft in Studio, then open the app on your iPhone. Tap the button: the about screen slides in with a back button, as on any iPhone app. ## What you learned - A screen is a tree of [components](https://docs.ynch.ai/reference/components.md) under one `Screen`. - Screens are reached through [routes](https://docs.ynch.ai/guides/navigation.md). - A `Button` navigates with an `action`. Next: [add a tab bar](https://docs.ynch.ai/tutorials/tab-bar.md) or [connect a database](https://docs.ynch.ai/tutorials/connect-a-database.md). --- # Send a notification > Have your own server send a notification to your iPhone as your app. Ynch sends you two kinds of notification: - **Build notices**: "New build ready for approval (Your App)" when a draft is uploaded. These arrive in Studio, by email and on your iPhone, with nothing to set up. - **App messages**: a line of text your own server sends, shown on your iPhone under your app's name. This tutorial sets one up. An app message always goes to the app's owner. Apps have one owner today. ## 1. Allow notifications on your iPhone Open the Ynch app while signed in and allow notifications when it asks. ## 2. Try it without a key In Studio, open your project's **Settings** and choose **Send test** under App notifications. "This is a test notification." should arrive on your phone within a few seconds. ## 3. Create a notification key Still in Settings, choose **Create notification key**. Studio shows the key once: copy it and keep it on your server. Do not put it in your app's files. The key allows one thing: sending a line of text to you as this app. ## 4. Send from your server ```sh curl -X POST https://studio.ynch.ai/notify/v1/projects/YOUR_PROJECT_ID \ -H "Authorization: Bearer YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"text":"New questions added!"}' ``` Your phone shows the app's name as the title and your text beneath it. The message is also listed under **Notifications** in Studio. A common setup is a database webhook or a scheduled job that calls this when something changes, for example when new rows are added. ## Rules - `text` is one line, 1 to 180 characters. Ynch sets the title, and a notification cannot carry a link. - Up to 100 notifications a day for each project. - Replacing the key in Settings stops the old one immediately. The full list of replies is in the [Notify API reference](https://docs.ynch.ai/reference/notify-api.md). --- # Add a tab bar > Put a bar of two to five tabs along the bottom of every screen, and choose how it looks. A tab bar gives your app the bottom navigation most iPhone apps have. Each tab opens one route. ## 1. Declare the tabs In `.ynch/navigation.json`, add a `tabBar` beside `routes`: ```json { "schemaVersion": "1.0.0", "initialRoute": "home", "routes": [ { "id": "home", "screenId": "home", "label": "Home", "parameters": {} }, { "id": "about", "screenId": "about", "label": "About", "parameters": {} } ], "tabBar": { "items": [ { "routeId": "home", "label": "Home", "icon": "home" }, { "routeId": "about", "label": "About", "icon": "activity" } ] } } ``` The rules: - Two to five tabs. - Each tab points at a different route, and that route takes no parameters. - The `initialRoute` must be one of the tabs. - `icon` is one of the [built-in icons](https://docs.ynch.ai/reference/icons.md). Selecting a tab opens its screen with nothing to go back to. Screens you open from there stay inside the tab. ## 2. Choose the look Three optional settings, each from a fixed list: | Setting | Values | Default | | --- | --- | --- | | `style` | `floating` (a rounded bar inset from the edges) or `full-width` (edge to edge, attached to the bottom) | `floating` | | `material` | `solid` (your theme's surface color) or `glass` | `solid` | | `labels` | `shown` or `hidden` (icons only) | `shown` | ```json "tabBar": { "items": [ ... ], "style": "full-width", "material": "glass" } ``` `glass` is Liquid Glass on iOS 26 and later. On earlier versions it is drawn as a blurred, translucent bar. The selected tab uses your theme's `primary` color and the others use `muted`. With `labels` hidden, the label is still what VoiceOver reads. ## 3. Check and upload ```sh npx ynch check npx ynch upload ``` The look options need a current version of the Ynch app on your iPhone. An older version shows the default bar. --- # Working with coding agents > How to have Claude Code, Cursor, Codex or another agent build a Ynch app well. Ynch apps are a good fit for coding agents: the format is small, closed and checkable. These habits get the best results. ## Give the agent the rules Point your agent at these docs. Every page is plain markdown when you add `.md` to its address, and [`/llms.txt`](https://docs.ynch.ai/llms.txt) is an index of all of them. For a ready-made instruction file, copy one from [For AI agents](https://docs.ynch.ai/agents.md) into your project as `AGENTS.md` or `CLAUDE.md`. ## A prompt to start from ```text Build a Ynch app in the .ynch folder of this project. Read https://docs.ynch.ai/llms.txt first, then the pages you need. Rules: - Only edit files inside .ynch. Do not change projectId or ynch.lock. - Use only the components, props, style options and icons in the reference. - After every change run `npx ynch check` and fix everything it reports. - Do not run `ynch upload`. I will do that myself. The app: ``` ## Let `ynch check` be the judge `ynch check` reports each problem with a code, the file and the exact place. Have the agent run it after every change and treat any output as a failure to fix. Do not let it work around an error by removing the thing you asked for. ## Keep secrets out Never paste database passwords or keys into the conversation or the files. The app only names a connection; the details live in Studio. Notification keys belong on your server. ## Review before you approve Uploading creates a draft, and nothing changes on your phone until you approve it in Studio. When the app uses a database, read the operations Studio lists before accepting: they are exactly what the app will be able to read and write. ## Common mistakes agents make | Mistake | Fix | | --- | --- | | Inventing a component or prop | Use the [component reference](https://docs.ynch.ai/reference/components.md) | | Raw colors or pixel sizes in `style` | Use tokens such as `$color.primary` and `$spacing.md` | | A screen with no route | Add it to `navigation.json` | | Leaving out `"props": {}` | Every component needs `props`, even when empty | | Underscores in names | Use hyphens; they map to underscores in the database | | An id that differs from the file name | Make them the same | --- # Models and operations > Describe your rows with models and declare each read and write as an operation. An app works with your database through two kinds of file. A **model** describes a row. An **operation** is one specific read or write. Start with [Connect a database](https://docs.ynch.ai/tutorials/connect-a-database.md) if you have not set one up. ## Models ```json { "schemaVersion": "1.0.0", "id": "workout", "identityField": "id", "fields": { "id": { "type": "integer", "required": true, "generated": true }, "name": { "type": "string", "required": true, "minLength": 1, "maxLength": 80 }, "duration": { "type": "integer", "required": true, "minimum": 1, "maximum": 600 }, "completed": { "type": "boolean", "required": true }, "day": { "type": "date", "required": false } } } ``` - Field types: `string`, `number`, `integer`, `boolean`, `date` (`YYYY-MM-DD`). - `identityField` names the field that identifies a row. Only it may be `generated` (set by the database). - Strings can have `minLength`, `maxLength` and a fixed `enum` list; numbers can have `minimum` and `maximum`. - A hyphen in a name is an underscore in the database: `topic-id` is the column `topic_id`. ## Operations Each operation names its table (`resource`), the columns it touches, and the model its rows match. | Kind | Does | Notes | | --- | --- | --- | | `list` | Reads many rows | Filters, sort and paging. Up to 100 rows a page. | | `get` | Reads one row | Filtered by the identity field. | | `insert` | Adds one row | `values` maps fields to parameters. | | `update` | Changes one row | Filtered by the identity field. | | `delete` | Removes one row | Filtered by the identity field. | A list with a filter: ```json { "schemaVersion": "1.0.0", "id": "list-cards", "kind": "list", "connection": "primary", "connector": "supabase", "resource": "cards", "columns": ["id", "topic-id", "question"], "responseModel": "card", "parameters": { "topic-id": { "type": "string", "required": true, "minLength": 36, "maxLength": 36 } }, "filters": [{ "field": "topic-id", "operator": "eq", "parameter": "topic-id" }], "sort": [{ "field": "id", "direction": "asc" }], "maxRows": 50, "pagination": { "mode": "offset", "defaultLimit": 20, "maxOffset": 10000 } } ``` - **Parameters** are the only values that come from the app at run time. They are typed like model fields. - **Filters** compare a field with a parameter using `eq`, `lt`, `lte`, `gt` or `gte`. Up to 10, all of which must match. - **Sort** takes up to three fields and, for a list, ends with the identity field. An insert: ```json { "schemaVersion": "1.0.0", "id": "create-workout", "kind": "insert", "connection": "primary", "connector": "supabase", "resource": "workouts", "columns": ["id", "name", "duration", "completed"], "responseModel": "workout", "parameters": { "name": { "type": "string", "required": true, "minLength": 1, "maxLength": 80 }, "duration": { "type": "integer", "required": true, "minimum": 1, "maximum": 600 }, "completed": { "type": "boolean", "required": true } }, "values": { "name": "name", "duration": "duration", "completed": "completed" }, "maxRows": 1 } ``` There are no joins, no SQL and no "or" conditions. If you need a combined view, create a view in your database and point an operation at it. ## Using operations on a screen - A [`RecordList`](https://docs.ynch.ai/reference/components/record-list.md) runs a `list` operation and draws its child for each row. - A [`Form`](https://docs.ynch.ai/reference/components/form.md) saves with an `insert` or `update` operation; its inputs bind to the model's fields. - A [`Button`](https://docs.ynch.ai/reference/components/button.md) can run an operation directly with `"action": { "type": "operation", ... }`. ## Approval Declaring an operation gives the app nothing by itself. After you make a version active, Studio lists each operation it asks for in plain words, and nothing runs until you accept. If you change an operation's table, columns, filters or values, it needs accepting again. You can revoke one at any time on the Database tab. ## Counting requests Each operation the app runs counts as one data request against your project's monthly allowance, shown on the app's detail screen and in Studio. --- # Navigation > Routes, passing a value to the next screen, and the tab bar. `navigation.json` lists every way to reach a screen. ```json { "schemaVersion": "1.0.0", "initialRoute": "topics", "routes": [ { "id": "topics", "screenId": "topics", "label": "Topics", "parameters": {} }, { "id": "questions", "screenId": "questions", "label": "Questions", "parameters": { "topic-id": { "type": "string", "required": true, "minLength": 36, "maxLength": 36 } } } ] } ``` - Every screen has exactly one route. - `initialRoute` is where the app opens. It cannot need parameters. - Going to a route pushes its screen with a back button, as on any iPhone app. ## Passing a value to the next screen A route can declare **parameters**: named, typed values the screen needs, such as which record to show. The button that navigates supplies them: ```json { "id": "study", "type": "Button", "props": { "label": "Study this topic" }, "action": { "type": "navigate", "routeId": "questions", "parameters": { "topic-id": { "source": "field", "model": "topic", "field": "id" } } } } ``` A parameter's value comes from one of three sources: | Source | Meaning | | --- | --- | | `{ "source": "literal", "value": 1 }` | A fixed value | | `{ "source": "field", "model": "topic", "field": "id" }` | A field of the current row (inside a `RecordList` or `Form`) | | `{ "source": "route", "parameter": "topic-id" }` | A parameter of the current screen's own route | On the next screen, an operation can use the route's parameter, for example to list only that topic's questions: ```json "bindings": { "items": { "operationId": "list-cards", "parameters": { "topic-id": { "source": "route", "parameter": "topic-id" } }, "pagination": { "offset": 0, "limit": 20 } } } ``` Types are checked and never converted: the text `"1"` is not the number `1`. ## Tab bar For bottom tabs, add a `tabBar`. See [Add a tab bar](https://docs.ynch.ai/tutorials/tab-bar.md). --- # Project layout > Every file in a .ynch folder and what it is for. A Ynch app is the `.ynch` folder inside your project directory. Nothing outside it is uploaded. ```text your-project/ .ynch/ project.json name, version, first screen ynch.lock the versions this app was written for theme.json colors, type, spacing, presets navigation.json routes and the optional tab bar connections.json which database connection the app uses (no secrets) screens/.json one file per screen; at least one models/.json optional: the shape of a row operations/.json optional: one approved read or write assets/.png optional: images (png, jpg, jpeg, webp) AGENTS.md optional: notes for your coding agent; never uploaded ``` ## Rules that apply everywhere - **Ids** are lowercase letters, digits and hyphens, starting with a letter, up to 64 characters: `new-workout`. - **A file's name is its id.** `screens/home.json` has `"id": "home"`. - **Strict JSON.** No comments, no trailing commas, no duplicate keys. - **Nothing extra.** A property or file the format does not define is an error, not ignored. This is what makes `ynch check` trustworthy. - **Every file starts with** `"schemaVersion": "1.0.0"`. ## project.json ```json { "schemaVersion": "1.0.0", "projectId": "proj_d3dd06e1387440087d576fe8", "name": "Field Notes", "version": "1.0.0", "entryScreen": "home" } ``` `projectId` is your Studio project. `ynch connect` fills it in; do not change it by hand. ## ynch.lock Pins the component catalog and style versions the app was written against. The CLI creates it. Leave it alone unless a migration guide says otherwise. ## The rest | File | Guide | | --- | --- | | `theme.json` | [Theme and colors](https://docs.ynch.ai/guides/theme.md) | | `navigation.json` | [Navigation](https://docs.ynch.ai/guides/navigation.md) | | `screens/` | [Screens and components](https://docs.ynch.ai/guides/screens-and-components.md) | | `connections.json`, `models/`, `operations/` | [Models and operations](https://docs.ynch.ai/guides/data.md) | The exact shape of each file is in [Project files](https://docs.ynch.ai/reference/files.md). --- # Releases and versions > Drafts, signed builds and the active version, and how to move between them. Every upload moves through three states. | State | What it means | | --- | --- | | **Draft** | Uploaded and waiting for you. Nobody can open it. | | **Signed** | You approved it and Studio signed that exact version. It gets the next build number. | | **Active** | The one signed build your iPhone opens. | ## The checklist When something is waiting, the **Releases** page shows a checklist with one current step: 1. **Approve & sign** the newest draft. 2. **Make it active.** 3. **Accept database changes**, when the newly active build asks for database access you have not accepted. This step is last because Studio judges database access for the active build. The Releases tab shows a count when drafts have arrived since you last looked, and you get a notification for each new draft. ## Builds Signed builds are numbered in the order you signed them (Build 1, Build 2, ...) and show when they were signed. The newest is marked. ## Going back Any signed build can be made active again with **Make active** on its row. Your phone opens whichever build is active the next time the app is opened or the list is refreshed. ## App version The version in **Settings** (for example `1.0.1`) is the version your app reports. It is separate from build numbers; change it when you want to mark a milestone. ## What uploading does not do `ynch upload` only ever creates a draft. Approving, signing and activating happen in Studio, by you. --- # Screens and components > How a screen is put together from components, presets and styles. A screen is one JSON file: a tree of [components](https://docs.ynch.ai/reference/components.md) with a `Screen` at the root. ```json { "schemaVersion": "1.0.0", "id": "home", "root": { "id": "home-root", "type": "Screen", "props": { "title": "Home", "safeArea": true, "scroll": true }, "preset": "page", "children": [ { "id": "welcome", "type": "Text", "props": { "text": "Welcome" }, "preset": "heading" }, { "id": "intro-card", "type": "Card", "props": {}, "preset": "panel", "children": [ { "id": "intro", "type": "Text", "props": { "text": "Everything you need today." } } ] } ] } } ``` ## Containers and leaves - **Containers** (`Screen`, `Stack`, `Row`, `Grid`, `Card`, `Form`) must have `children`. - **`RecordList`** has exactly one child: the template drawn for each row. - **Everything else** has no children. A `Screen` lays its children out top to bottom, like a `Stack`. Use `Row` for side by side and `Grid` for one or two columns. ## Looks: presets first, then style Give a component a `preset` to reuse a named look from your [theme](https://docs.ynch.ai/guides/theme.md), and a `style` for one-off changes. Style values refer to theme tokens: ```json { "id": "total", "type": "Text", "props": { "text": "42" }, "preset": "heading", "style": { "color": "$color.primary", "textAlign": "center" } } ``` All the options are in [Style options](https://docs.ynch.ai/reference/style.md). There is no free-form color, size or position. ## Showing data Inside a `RecordList` or a `Form`, a `Text`, `Badge` or input can show a field with `bindings.value`: ```json { "id": "topic-name", "type": "Text", "props": {}, "bindings": { "value": { "model": "topic", "field": "name" } } } ``` Values are always shown as plain text. See [Models and operations](https://docs.ynch.ai/guides/data.md). ## Reacting to taps Only two things act: a `Button` (on tap) and a `Form` (on save). A button either navigates or runs an operation: ```json { "id": "open-about", "type": "Button", "props": { "label": "About" }, "action": { "type": "navigate", "routeId": "about", "parameters": {} } } ``` ## Limits Up to 50 screens, 2,000 components in total, and components nested at most 12 deep. See [Limits](https://docs.ynch.ai/reference/limits.md). --- # Theme and colors > Set your app's colors, type, spacing and reusable presets in theme.json. `theme.json` holds your app's design tokens and presets. Components refer to them by name, so changing a color here changes it everywhere. ```json { "schemaVersion": "1.0.0", "styleVersion": "0.1.0", "tokens": { "colors": { "background": "#F8FAFC", "surface": "#FFFFFF", "primary": "#2563EB", "secondary": "#7C3AED", "text": "#0F172A", "muted": "#64748B", "border": "#CBD5E1", "error": "#DC2626", "success": "#16A34A" }, "typography": { "body": { "fontFamily": "system", "fontSize": 16, "fontWeight": 400, "lineHeight": 24 }, "title": { "fontFamily": "system", "fontSize": 28, "fontWeight": 700, "lineHeight": 36 }, "caption": { "fontFamily": "system", "fontSize": 12, "fontWeight": 400, "lineHeight": 16 } }, "spacing": { "none": 0, "xs": 4, "sm": 8, "md": 16, "lg": 24, "xl": 32 }, "radii": { "none": 0, "sm": 4, "md": 8, "lg": 16 } }, "presets": { "page": { "padding": "$spacing.md", "gap": "$spacing.md", "backgroundColor": "$color.background" }, "panel": { "padding": "$spacing.md", "radius": "$radius.md", "backgroundColor": "$color.surface", "shadow": "subtle" }, "heading": { "typography": "$typography.title", "color": "$color.text" } } } ``` ## Tokens - **All nine colors are required**, each as `#RRGGBB`. There are no hidden defaults. - **Typography** has three sizes: `body`, `title`, `caption`. The font is always the iPhone system font. - **Spacing** and **radii** are whole numbers of points. Where each color is used is listed in [Style options](https://docs.ynch.ai/reference/style.md#color-tokens). ## Presets A preset is a named bundle of style options. Define the looks you repeat (a page, a panel, a heading, a note) once, and use them with `"preset": "panel"`. You can add as many presets as you like. ## A dark theme There is one theme per app. For a dark app, set dark values: ```json "colors": { "background": "#0B1020", "surface": "#141A33", "primary": "#8F82FF", "secondary": "#4FA8FF", "text": "#EEF0FF", "muted": "#A3AAD6", "border": "#2A3166", "error": "#FF7088", "success": "#3DDC97" } ``` Check that `text` on `background` and on `surface` is easy to read; Ynch does not adjust colors for you. --- # CLI > Every ynch command. Install the CLI in your project and run it with `npx`: ```sh npm install --save-dev @ynch/cli@beta npx ynch ``` It needs Node.js 22 or later. ## Everyday commands | Command | What it does | | --- | --- | | `ynch connect` | Connects this folder to one of your Studio projects so you can upload drafts. Prints a Studio link to approve, then lets you pick or create the project. In an empty folder it also writes a starter `.ynch`. | | `ynch check` | Validates the `.ynch` folder and the images it uses. Writes nothing and uses no network. | | `ynch upload` | Builds the app and uploads it to the connected project as a draft. | | `ynch forget --draft` | Removes this computer's draft connection. Run it before `connect` when an upload says there is no active connection. | ## Other commands | Command | What it does | | --- | --- | | `ynch init [--name NAME] [--project-id ID]` | Writes a starter `.ynch` without connecting to Studio. | | `ynch build` | Builds the unsigned bundle into `dist/` and prints its Build ID, without uploading. | | `ynch upload PROJECT_ID BUILD_ID` | Uploads one specific build, approved through a Studio page each time. | | `ynch login` | Opens Studio in your browser to sign in. | | `ynch link PROJECT_ID` | Links this folder to a project for read-only status. | | `ynch status` | Shows the linked project's status. | | `ynch forget` | Removes the read-only link. | ## Good to know - A draft connection lasts as long as the Studio session that approved it. - An upload is at most 256 KB and never changes what is live. Approving and activating happen in [Studio](https://docs.ynch.ai/guides/releases.md). - The CLI never runs anything in your app's files and never sends them anywhere except Studio, on `upload`. - A project over its plan's storage refuses new uploads until you free space or change plan. --- # Components > The 18 native components an app can use. An app's screens are built from exactly these 18 components (catalog 1.0.0). Each one is drawn with a native iPhone control. There are no custom components, and a definition that uses anything else does not validate. ## Layout | Component | What it does | | --- | --- | | [Screen](https://docs.ynch.ai/reference/components/screen.md) | The root of every screen file. It sets the title, whether the content scrolls and whether it stays inside the safe area. | | [Stack](https://docs.ynch.ai/reference/components/stack.md) | Lays its children out top to bottom. | | [Row](https://docs.ynch.ai/reference/components/row.md) | Lays its children out side by side. | | [Grid](https://docs.ynch.ai/reference/components/grid.md) | Arranges its children in one or two equal columns. | | [Card](https://docs.ynch.ai/reference/components/card.md) | A container, usually styled as a raised panel. | | [Divider](https://docs.ynch.ai/reference/components/divider.md) | A thin line between sections. | ## Visual | Component | What it does | | --- | --- | | [Text](https://docs.ynch.ai/reference/components/text.md) | Shows text: either fixed text or a value from your data. | | [Image](https://docs.ynch.ai/reference/components/image.md) | Shows an image bundled with the app. | | [Icon](https://docs.ynch.ai/reference/components/icon.md) | Shows one of the built-in icons. | | [Badge](https://docs.ynch.ai/reference/components/badge.md) | A short label in a pill. | | [Button](https://docs.ynch.ai/reference/components/button.md) | A button that goes to another screen or runs an operation. | ## Input | Component | What it does | | --- | --- | | [Input](https://docs.ynch.ai/reference/components/input.md) | A single-line field for text, a number or an email address. | | [TextArea](https://docs.ynch.ai/reference/components/text-area.md) | A multi-line text field. | | [Select](https://docs.ynch.ai/reference/components/select.md) | Lets the user pick one option from a list. | | [Switch](https://docs.ynch.ai/reference/components/switch.md) | An on/off switch. | | [DatePicker](https://docs.ynch.ai/reference/components/date-picker.md) | Lets the user pick a date. | ## Data | Component | What it does | | --- | --- | | [RecordList](https://docs.ynch.ai/reference/components/record-list.md) | Loads rows with a list operation and draws its one child once per row. | | [Form](https://docs.ynch.ai/reference/components/form.md) | Collects values for one model and saves them with an insert or update operation. | ## The shape of a component ```json { "id": "welcome", "type": "Text", "props": { "text": "Welcome" }, "preset": "heading", "style": { "color": "$color.primary" } } ``` - `id`: lowercase letters, digits and hyphens, unique within the screen. - `type`: one of the components above. - `props`: always present, even when empty (`{}`). - `preset`: the name of a style preset from `theme.json`. Optional. - `style`: style options for this one component, applied after the preset. Optional. - `children`: required on containers, not allowed on the rest. --- # Badge > A short label in a pill. A short label in a pill. **Use it for:** Status and counts. Like Text, it can show fixed text or a field. - Category: Visual - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `text` | No | text, up to 200 characters | The text to show. Leave it out when the text comes from `bindings.value`. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "status", "type": "Badge", "props": { "text": "New" } } ``` --- # Button > A button that goes to another screen or runs an operation. A button that goes to another screen or runs an operation. **Use it for:** The only component that reacts to a tap, apart from submitting a Form. - Category: Visual - Children: None - Data: None - Action: On tap: go to a route or run an operation ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | | `disabled` | No | `true` or `false` | Show it greyed out and ignore taps. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "view", "type": "Button", "props": { "label": "View workouts" }, "action": { "type": "navigate", "routeId": "workouts", "parameters": {} } } ``` --- # Card > A container, usually styled as a raised panel. A container, usually styled as a raised panel. **Use it for:** Group related content. Give it a preset or style for background, radius and shadow. - Category: Layout - Children: Any number - Data: None - Action: None ## Props None. Write `"props": {}`; the look comes from `preset` and `style`. Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "tip", "type": "Card", "props": {}, "preset": "panel", "children": [ { "id": "tip-text", "type": "Text", "props": { "text": "Rest days count too." } } ] } ``` --- # DatePicker > Lets the user pick a date. Lets the user pick a date. **Use it for:** A date field, inside a Form. - Category: Input - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | | `required` | No | `true` or `false` | The form cannot be saved while this is empty. | | `disabled` | No | `true` or `false` | Show it greyed out and ignore taps. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "date", "type": "DatePicker", "props": { "label": "Workout date", "required": true }, "bindings": { "value": { "model": "workout", "field": "date" } } } ``` --- # Divider > A thin line between sections. A thin line between sections. **Use it for:** Separate groups inside a Stack or Card. - Category: Layout - Children: None - Data: None - Action: None ## Props None. Write `"props": {}`; the look comes from `preset` and `style`. Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "rule", "type": "Divider", "props": {} } ``` --- # Form > Collects values for one model and saves them with an insert or update operation. Collects values for one model and saves them with an insert or update operation. **Use it for:** Creating and editing records. Its inputs bind to the fields of the form's model. - Category: Data - Children: Any number - Data: None - Action: On save: run an insert or update operation ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `model` | Yes | text in a fixed format | The model this form edits. | | `submitLabel` | Yes | text, up to 200 characters | The label of the save button. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "workout-form", "type": "Form", "props": { "model": "workout", "submitLabel": "Save workout" }, "children": [ { "id": "identity", "type": "Text", "props": {}, "bindings": { "value": { "model": "workout", "field": "id" } } }, { "id": "name", "type": "Input", "props": { "label": "Workout name", "inputType": "text", "required": true }, "bindings": { "value": { "model": "workout", "field": "name" } } }, { "id": "duration", "type": "Input", "props": { "label": "Minutes", "inputType": "number", "required": true }, "bindings": { "value": { "model": "workout", "field": "duration" } } }, { "id": "category", "type": "Select", "props": { "label": "Category", "required": true, "options": [ { "label": "Strength", "value": "strength" }, { "label": "Cardio", "value": "cardio" }, { "label": "Mobility", "value": "mobility" } ] }, "bindings": { "value": { "model": "workout", "field": "category" } } }, { "id": "completed", "type": "Switch", "props": { "label": "Completed", "required": true }, "bindings": { "value": { "model": "workout", "field": "completed" } } }, { "id": "date", "type": "DatePicker", "props": { "label": "Workout date", "required": true }, "bindings": { "value": { "model": "workout", "field": "date" } } }, { "id": "notes", "type": "TextArea", "props": { "label": "Notes", "maxLength": 1000 }, "bindings": { "value": { "model": "workout", "field": "notes" } } } ], "action": { "type": "operation", "operationId": "update-workout", "parameters": { "id": { "source": "field", "model": "workout", "field": "id" }, "name": { "source": "field", "model": "workout", "field": "name" }, "duration": { "source": "field", "model": "workout", "field": "duration" }, "completed": { "source": "field", "model": "workout", "field": "completed" }, "date": { "source": "field", "model": "workout", "field": "date" }, "notes": { "source": "field", "model": "workout", "field": "notes" }, "category": { "source": "field", "model": "workout", "field": "category" } } }, "form": { "mode": "edit", "initialData": { "type": "operation", "operationId": "get-workout", "parameters": { "id": { "source": "route", "parameter": "id" } } }, "lifecycle": { "validation": "submit", "concurrency": "single-flight", "retry": "manual", "success": "stay", "failure": "preserve-values" } } } ``` --- # Grid > Arranges its children in one or two equal columns. Arranges its children in one or two equal columns. **Use it for:** Tiles of the same kind, such as stats or shortcuts. - Category: Layout - Children: Any number - Data: None - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `columns` | Yes | whole number, 1 to 2 | Number of columns. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "stats", "type": "Grid", "props": { "columns": 2 }, "style": { "gap": "$spacing.md" }, "children": [ { "id": "stat-one", "type": "Card", "props": {}, "preset": "panel", "children": [ { "id": "stat-one-text", "type": "Text", "props": { "text": "12 workouts" } } ] }, { "id": "stat-two", "type": "Card", "props": {}, "preset": "panel", "children": [ { "id": "stat-two-text", "type": "Text", "props": { "text": "340 minutes" } } ] } ] } ``` --- # Icon > Shows one of the built-in icons. Shows one of the built-in icons. **Use it for:** Mark a row or a button. `label` is what VoiceOver reads. - Category: Visual - Children: None - Data: None - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `name` | Yes | `activity`, `plus`, `check`, `chevron-right`, `trash`, `home`, `edit` | Which icon to show. | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "done-icon", "type": "Icon", "props": { "name": "check", "label": "Done" }, "style": { "color": "$color.success" } } ``` --- # Image > Shows an image bundled with the app. Shows an image bundled with the app. **Use it for:** Logos and illustrations. Images come from the project's `assets` folder, never from a URL. - Category: Visual - Children: None - Data: None - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `asset` | Yes | text in a fixed format | Path of an image in the project, for example `assets/logo.png`. | | `alt` | Yes | text, up to 200 characters | What the image shows, for VoiceOver. | | `fit` | Yes | `contain`, `cover` | `contain` shows the whole image; `cover` fills the space and may crop. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "hero", "type": "Image", "props": { "asset": "assets/fitness.png", "alt": "Fitness app mark", "fit": "contain" }, "style": { "radius": "$radius.sm" } } ``` The image file must exist in the project at `.ynch/assets/logo.png`. PNG, JPEG and WebP are accepted. --- # Input > A single-line field for text, a number or an email address. A single-line field for text, a number or an email address. **Use it for:** Inside a Form, bound to one field of the form's model. - Category: Input - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | | `required` | No | `true` or `false` | The form cannot be saved while this is empty. | | `disabled` | No | `true` or `false` | Show it greyed out and ignore taps. | | `inputType` | Yes | `text`, `number`, `email` | Which keyboard to show and what kind of value to accept. | | `placeholder` | No | text, up to 200 characters | Grey hint text shown while the field is empty. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "name", "type": "Input", "props": { "label": "Workout name", "inputType": "text", "required": true }, "bindings": { "value": { "model": "workout", "field": "name" } } } ``` --- # RecordList > Loads rows with a list operation and draws its one child once per row. Loads rows with a list operation and draws its one child once per row. **Use it for:** Any list of records from your database, with paging built in. - Category: Data - Children: Exactly one (the row template) - Data: A list operation (bindings.items) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `pageSize` | Yes | whole number, 1 to 100 | How many rows to load at a time. | | `emptyText` | Yes | text, up to 200 characters | Shown when there are no rows. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "workouts", "type": "RecordList", "props": { "pageSize": 25, "emptyText": "No workouts yet" }, "bindings": { "items": { "operationId": "list-workouts", "parameters": {}, "pagination": { "offset": 0, "limit": 25 } } }, "children": [ { "id": "item", "type": "Stack", "props": {}, "children": [ { "id": "name", "type": "Text", "props": {}, "bindings": { "value": { "model": "workout", "field": "name" } } }, { "id": "category", "type": "Badge", "props": {}, "bindings": { "value": { "model": "workout", "field": "category" } } }, { "id": "duration", "type": "Text", "props": {}, "bindings": { "value": { "model": "workout", "field": "duration" } } }, { "id": "remove", "type": "Button", "props": { "label": "Delete workout" }, "action": { "type": "operation", "operationId": "delete-workout", "parameters": { "id": { "source": "field", "model": "workout", "field": "id" } } } }, { "id": "edit-selected", "type": "Button", "props": { "label": "Edit workout" }, "action": { "type": "navigate", "routeId": "edit-workout", "parameters": { "id": { "source": "field", "model": "workout", "field": "id" } } } } ] } ] } ``` --- # Row > Lays its children out side by side. Lays its children out side by side. **Use it for:** Put a label beside a value, or two buttons next to each other. - Category: Layout - Children: Any number - Data: None - Action: None ## Props None. Write `"props": {}`; the look comes from `preset` and `style`. Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "summary", "type": "Row", "props": {}, "style": { "justify": "space-between", "align": "center" }, "children": [ { "id": "summary-label", "type": "Text", "props": { "text": "This week" } }, { "id": "summary-count", "type": "Badge", "props": { "text": "4 done" } } ] } ``` --- # Screen > The root of every screen file. It sets the title, whether the content scrolls and whether it stays inside the safe area. The root of every screen file. It sets the title, whether the content scrolls and whether it stays inside the safe area. **Use it for:** One per screen, always at the top. A Screen cannot sit inside another component. - Category: Layout - Children: Any number - Data: None - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `title` | No | text, up to 200 characters | Shown in the navigation bar. | | `safeArea` | No | `true` or `false` | Keep content clear of the notch and home indicator. Default `true`. | | `scroll` | No | `true` or `false` | Let the content scroll. Default `true`. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "home-root", "type": "Screen", "props": { "title": "Home", "safeArea": true, "scroll": true }, "preset": "page", "children": [ { "id": "welcome", "type": "Text", "props": { "text": "Welcome" } } ] } ``` --- # Select > Lets the user pick one option from a list. Lets the user pick one option from a list. **Use it for:** A fixed set of choices for a text field, inside a Form. - Category: Input - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | | `required` | No | `true` or `false` | The form cannot be saved while this is empty. | | `disabled` | No | `true` or `false` | Show it greyed out and ignore taps. | | `options` | Yes | list of 1 to 50 items | The choices, each with a `label` to show and a `value` to store. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "category", "type": "Select", "props": { "label": "Category", "required": true, "options": [ { "label": "Strength", "value": "strength" }, { "label": "Cardio", "value": "cardio" }, { "label": "Mobility", "value": "mobility" } ] }, "bindings": { "value": { "model": "workout", "field": "category" } } } ``` --- # Stack > Lays its children out top to bottom. Lays its children out top to bottom. **Use it for:** The default way to arrange things. Use `gap` in its style for spacing. - Category: Layout - Children: Any number - Data: None - Action: None ## Props None. Write `"props": {}`; the look comes from `preset` and `style`. Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "intro", "type": "Stack", "props": {}, "style": { "gap": "$spacing.sm" }, "children": [ { "id": "intro-title", "type": "Text", "props": { "text": "Today" }, "preset": "heading" }, { "id": "intro-body", "type": "Text", "props": { "text": "Three workouts planned." } } ] } ``` --- # Switch > An on/off switch. An on/off switch. **Use it for:** A yes/no field, inside a Form. - Category: Input - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | | `required` | No | `true` or `false` | The form cannot be saved while this is empty. | | `disabled` | No | `true` or `false` | Show it greyed out and ignore taps. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "completed", "type": "Switch", "props": { "label": "Completed", "required": true }, "bindings": { "value": { "model": "workout", "field": "completed" } } } ``` --- # Text > Shows text: either fixed text or a value from your data. Shows text: either fixed text or a value from your data. **Use it for:** Headings, paragraphs and values. Inside a list or form it can show a field with `bindings.value`. - Category: Visual - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `text` | No | text, up to 2000 characters | The text to show. Leave it out when the text comes from `bindings.value`. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example ```json { "id": "heading", "type": "Text", "props": { "text": "Welcome back" }, "preset": "heading" } ``` --- # TextArea > A multi-line text field. A multi-line text field. **Use it for:** Notes and longer answers, inside a Form. - Category: Input - Children: None - Data: One field (bindings.value) - Action: None ## Props | Prop | Required | Accepts | What it does | | --- | --- | --- | --- | | `label` | Yes | text, up to 200 characters | The visible label, also read by VoiceOver. | | `required` | No | `true` or `false` | The form cannot be saved while this is empty. | | `disabled` | No | `true` or `false` | Show it greyed out and ignore taps. | | `maxLength` | No | whole number, 1 to 10000 | The most characters the user can type. | Every component also accepts `id` (required, unique on its screen), and the optional `preset` and `style` described in [Style options](https://docs.ynch.ai/reference/style.md). ## Example From the fitness example project: ```json { "id": "notes", "type": "TextArea", "props": { "label": "Notes", "maxLength": 1000 }, "bindings": { "value": { "model": "workout", "field": "notes" } } } ``` --- # Project files > The exact shape of every file in a .ynch folder. Every JSON file starts with `"schemaVersion": "1.0.0"`. Objects are closed: a property not listed here is an error. See [Project layout](https://docs.ynch.ai/guides/project-layout.md) for the folder as a whole. ## project.json | Property | Required | Value | | --- | --- | --- | | `projectId` | Yes | `proj_` followed by 24 hex characters. Set by `ynch connect`. | | `name` | Yes | The app's name. | | `version` | Yes | Three numbers, for example `1.0.0`. | | `entryScreen` | Yes | The id of a screen. | ## navigation.json | Property | Required | Value | | --- | --- | --- | | `initialRoute` | Yes | The id of a route with no required parameters. | | `routes` | Yes | 1 to 50 routes: `{ id, screenId, label, parameters }`. | | `tabBar` | No | `{ items, style, material, labels }`. See [Add a tab bar](https://docs.ynch.ai/tutorials/tab-bar.md). | `tabBar.items` holds 2 to 5 of `{ routeId, label, icon }`. `style` is `floating` or `full-width`, `material` is `solid` or `glass`, `labels` is `shown` or `hidden`. ## theme.json | Property | Required | Value | | --- | --- | --- | | `styleVersion` | Yes | `0.1.0` | | `tokens` | Yes | `colors`, `typography`, `spacing`, `radii`, all complete. | | `presets` | Yes | Named style objects. May be empty. | See [Theme and colors](https://docs.ynch.ai/guides/theme.md) and [Style options](https://docs.ynch.ai/reference/style.md). ## connections.json ```json { "schemaVersion": "1.0.0", "connections": { "primary": { "cloudConnectionId": "conn_main", "provider": "supabase", "userAuth": { "userColumn": "user-id" } } } } ``` | Property | Required | Value | | --- | --- | --- | | `cloudConnectionId` | Yes | `conn_` followed by a name. A label only; it holds no address or secret. | | `provider` | Yes | `supabase` or `mysql` | | `userAuth.userColumn` | No | Supabase only. Turns on [app sign-in](https://docs.ynch.ai/tutorials/app-sign-in.md) and names the user id field. | An app that uses no database has `"connections": {}`. An upload may declare at most one connection. ## screens/.json | Property | Required | Value | | --- | --- | --- | | `id` | Yes | Same as the file name. | | `root` | Yes | A [`Screen`](https://docs.ynch.ai/reference/components/screen.md) component. | Each component has `id`, `type`, `props`, and optionally `preset`, `style`, `children`, `bindings` and `action`, as its [reference page](https://docs.ynch.ai/reference/components.md) allows. ## models/.json | Property | Required | Value | | --- | --- | --- | | `id` | Yes | Same as the file name. | | `identityField` | Yes | A required `string` or `integer` field. | | `fields` | Yes | A map of field name to `{ type, required, ... }`. | Field types are `string` (`minLength`, `maxLength` up to 10,000, `enum` of up to 50 values), `number` and `integer` (`minimum`, `maximum`), `boolean`, and `date`. ## operations/.json | Property | Required | Value | | --- | --- | --- | | `id` | Yes | Same as the file name. | | `kind` | Yes | `list`, `get`, `insert`, `update` or `delete` | | `connection` | Yes | A name from `connections.json`. | | `connector` | Yes | `supabase` or `mysql`, matching the connection. | | `resource` | Yes | The table or view. | | `columns` | Yes | 1 to 100 fields of the response model. | | `responseModel` | Yes | The id of a model. | | `parameters` | Yes | A map of typed parameters. May be empty. | | `maxRows` | Yes | 1 to 100 for `list`; 1 for the rest. | | `filters` | By kind | Up to 10 of `{ field, operator, parameter }`. `get`, `update` and `delete` must filter on the identity field. | | `sort` | `list`, `get` | Up to 3 of `{ field, direction }`. | | `pagination` | `list` | `{ "mode": "offset", "defaultLimit", "maxOffset" }` | | `values` | `insert`, `update` | A map of field to parameter. | See [Models and operations](https://docs.ynch.ai/guides/data.md) for complete examples. ## assets/ PNG, JPEG or WebP files in one flat folder, named with lowercase letters, digits and hyphens. Each is at most 4,096 pixels a side. Animated images are not accepted. --- # Icons > The built-in icons for Icon components and tab bars. 7 icons are built in. Use the name in an [Icon](https://docs.ynch.ai/reference/components/icon.md) component or as a tab's `icon` in the [tab bar](https://docs.ynch.ai/tutorials/tab-bar.md). On iPhone each one is drawn with the matching system symbol, so it follows the user's text size and weight settings. | Name | Good for | | --- | --- | | `activity` | Activity, stats, progress | | `plus` | Add or create | | `check` | Done or selected | | `chevron-right` | Goes to another screen | | `trash` | Delete | | `home` | Home or main tab | | `edit` | Edit | Custom icons are not supported. For a picture of your own, use an [Image](https://docs.ynch.ai/reference/components/image.md). --- # Limits > Sizes and counts an app must stay within. ## An app | What | Limit | | --- | --- | | Uploaded app (built bundle) | 256 KB | | Screens | 50 | | Components, all screens together | 2,000 | | Component nesting | 12 levels | | Models | 100 | | Operations | 100 | | Database connections | 1 | | Tabs in a tab bar | 2 to 5 | | One source file | 2 MB | | Image size | 4,096 pixels a side, 16 megapixels | ## Data | What | Limit | | --- | --- | | Rows in one page of a list | 100 | | Furthest a list can page | Offset 10,000 | | Filters on an operation | 10 | | Sort fields | 3 | | Text field length | 10,000 characters | | Options in an `enum` or a Select | 50 | ## Notifications | What | Limit | | --- | --- | | App message text | 180 characters, one line | | App messages per project | 100 a day | ## Plans Each project has a plan with a storage allowance and a monthly number of data requests. Your current usage is on the project's **Billing** tab in Studio and on the app's detail screen on your iPhone. --- # Notify API > Send a notification to your app's owner from your own server. One endpoint. It sends a line of text to the project's owner, shown under the app's name. Setup is in [Send a notification](https://docs.ynch.ai/tutorials/notifications.md). ```http POST https://studio.ynch.ai/notify/v1/projects/{projectId} Authorization: Bearer ynk_... Content-Type: application/json {"text":"New questions added!"} ``` ## Request | Part | Value | | --- | --- | | `{projectId}` | Your project's id, `proj_...`, shown under Developer details on the project page. | | `Authorization` | `Bearer` and the project's notification key. | | Body | A JSON object with exactly one property, `text`: one line, 1 to 180 characters, no leading or trailing spaces. | ## Replies | Status | Body | Meaning | | --- | --- | --- | | `202` | `{"status":"sent"}` | Listed in Studio and handed to Apple for each of the owner's iPhones. | | `400` | `{"error":"bad_request", ...}` | The body is not `{"text":"..."}` with one valid line. | | `401` | `{"error":"unauthenticated"}` | No key, a wrong or replaced key, or a key for another project. | | `404` | `{"error":"not_found"}` | Wrong path or method. | | `429` | `{"error":"rate_limited", ...}` | The project has sent its 100 notifications for the day (UTC). | | `503` | `{"error":"unavailable"}` | Try again later. | ## Notes - The title is always the app's name. A notification cannot carry a link, an image or a custom title. - `202` means accepted. Delivery to a phone depends on Apple and on notifications being allowed for the Ynch app. - The key is stored by Ynch only as a hash. Replace it in the project's Settings if it may have leaked; the old key stops working immediately. --- # Style options > Colors, spacing, type and layout options for components. An app's look comes from two places: the **tokens** in `theme.json` (your colors, type sizes, spacing and corner radii) and the **style** on each component, which refers to those tokens by name. There is no CSS, and no values outside this page (style 0.1.0). ## Style on a component | Option | Accepts | What it does | | --- | --- | --- | | `color` | `$color.background`, `$color.surface`, `$color.primary`, `$color.secondary`, `$color.text`, `$color.muted`, `$color.border`, `$color.error`, `$color.success` | Text and icon color. | | `backgroundColor` | `$color.background`, `$color.surface`, `$color.primary`, `$color.secondary`, `$color.text`, `$color.muted`, `$color.border`, `$color.error`, `$color.success` | Fill behind the component. | | `typography` | `$typography.body`, `$typography.title`, `$typography.caption` | Text size and weight, from the theme. | | `padding` | `$spacing.none`, `$spacing.xs`, `$spacing.sm`, `$spacing.md`, `$spacing.lg`, `$spacing.xl` | Space inside the edges. | | `margin` | `$spacing.none`, `$spacing.xs`, `$spacing.sm`, `$spacing.md`, `$spacing.lg`, `$spacing.xl` | Space outside the edges. | | `gap` | `$spacing.none`, `$spacing.xs`, `$spacing.sm`, `$spacing.md`, `$spacing.lg`, `$spacing.xl` | Space between children. | | `borderColor` | `$color.background`, `$color.surface`, `$color.primary`, `$color.secondary`, `$color.text`, `$color.muted`, `$color.border`, `$color.error`, `$color.success` | Border color. Needs `borderWidth`. | | `borderWidth` | whole number, 0 to 4 | Border thickness in points. | | `radius` | `$radius.none`, `$radius.sm`, `$radius.md`, `$radius.lg` | Corner rounding. | | `shadow` | `none`, `subtle`, `medium` | Drop shadow. | | `width` | `auto`, `fill`, `half` | `fill` takes the full width, `half` takes half. | | `height` | `auto`, `fill` | `fill` takes the available height. | | `align` | `start`, `center`, `end`, `stretch` | How children line up across the layout direction. | | `justify` | `start`, `center`, `end`, `space-between` | How children are spread along the layout direction. | | `flex` | whole number, 0 to 1 | `1` lets the component grow to fill a Row or Stack. | | `textAlign` | `left`, `center`, `right` | Text alignment. | ## Color tokens Every theme defines all 9 colors, as `#RRGGBB`. The starter project's values are shown. | Token | Starter value | Used for | | --- | --- | --- | | `$color.background` | `#F8FAFC` | The screen behind everything | | `$color.surface` | `#FFFFFF` | Cards and the tab bar | | `$color.primary` | `#2563EB` | Buttons, links and the selected tab | | `$color.secondary` | `#7C3AED` | A second accent | | `$color.text` | `#0F172A` | Main text | | `$color.muted` | `#64748B` | Secondary text and unselected tabs | | `$color.border` | `#CBD5E1` | Lines and outlines | | `$color.error` | `#DC2626` | Problems | | `$color.success` | `#16A34A` | Confirmation | ## Spacing, radius and type tokens | Kind | Names | Starter values | | --- | --- | --- | | `$spacing` | `none`, `xs`, `sm`, `md`, `lg`, `xl` | 0, 4, 8, 16, 24, 32 points | | `$radius` | `none`, `sm`, `md`, `lg` | 0, 4, 8, 16 points | | `$typography` | `body`, `title`, `caption` | 16/24 weight 400, 28/36 weight 700, 12/16 weight 400 | Type always uses the iPhone's system font. Sizes run from 10 to 48, weights are 400, 500, 600 or 700. ## Presets A preset is a named style in `theme.json` that components reuse with `"preset": "name"`. The starter project defines: ```json { "page": { "padding": "$spacing.md", "gap": "$spacing.md", "backgroundColor": "$color.background" }, "panel": { "padding": "$spacing.md", "radius": "$radius.md", "backgroundColor": "$color.surface", "shadow": "subtle" }, "heading": { "typography": "$typography.title", "color": "$color.text" } } ``` A component's own `style` is applied after its preset, so it can override single options. --- # Examples > Complete apps to learn from, and what each one demonstrates. Each example is a complete, valid `.ynch` folder. ## Starter What `ynch connect` writes into an empty folder: one screen, one route and a theme with three presets. The place to begin. Walkthrough: [Build your first app](https://docs.ynch.ai/tutorials/first-app.md). ## Field Guide An eight-screen hiking guide with no database. It is the best reference for layout and styling. - Uses every style option: padding, margin, gap, colors, type, radius, shadow, border, width, height, align, justify, flex and text alignment. - Uses all seven icons and five bundled images. - Passes a number to a screen through a typed route parameter. Read with: [Screens and components](https://docs.ynch.ai/guides/screens-and-components.md), [Style options](https://docs.ynch.ai/reference/style.md). ## Fitness A workout log with full create, read, update and delete. - One model (`workout`) and five operations: list, get, create, update, delete. - A `RecordList` with paging, a create form with defaults, and an edit form that loads the record first. - A button that deletes the current row. Read with: [Models and operations](https://docs.ynch.ai/guides/data.md). ## Realty Ready A real-estate exam study app on a live Supabase database. - Four tables: topics, questions, answer choices and per-user progress. - A list filtered by the previous screen's selection. - [App sign-in](https://docs.ynch.ai/tutorials/app-sign-in.md): each user records and sees their own progress. - A full-width glass [tab bar](https://docs.ynch.ai/tutorials/tab-bar.md). Read with: [Connect a database](https://docs.ynch.ai/tutorials/connect-a-database.md). --- # For AI agents > Machine-readable copies of these docs and ready-made instruction files for coding agents. These docs are written to be used by coding agents as well as people. ## Machine-readable docs | Address | What it is | | --- | --- | | [`/llms.txt`](https://docs.ynch.ai/llms.txt) | An index of every page, with a one-line description and a link to its markdown. | | [`/llms-full.txt`](https://docs.ynch.ai/llms-full.txt) | Every page in one file. | | Any page address plus `.md` | That page as plain markdown, for example [`/reference/components/button.md`](https://docs.ynch.ai/reference/components/button.md). | ## Instruction files Copy one into your project as `AGENTS.md` (or `CLAUDE.md`, or your agent's rules file). Each is short, self-contained and kept in step with the reference. | File | Use it when the agent is | | --- | --- | | [`/agents/build-an-app.md`](https://docs.ynch.ai/agents/build-an-app.md) | Building or changing any Ynch app. Start with this one. | | [`/agents/screens.md`](https://docs.ynch.ai/agents/screens.md) | Laying out screens and styling them. | | [`/agents/data.md`](https://docs.ynch.ai/agents/data.md) | Adding models, operations, lists and forms. | | [`/agents/navigation.md`](https://docs.ynch.ai/agents/navigation.md) | Adding routes, parameters or a tab bar. | ## Rules every agent should follow 1. Edit only files inside `.ynch`. Never change `projectId` or `ynch.lock`. 2. Use only what the reference lists. There are no custom components, no CSS, no code and no SQL. 3. Run `npx ynch check` after every change and fix everything it reports. 4. Never put passwords, keys or tokens in any file. 5. Do not upload. The person approves each version in Studio.