Skip to content

Build your first app

You will build a home screen and an about screen, and a button that goes from one to the other. Finish the quick start first so you have a connected .ynch folder.

.ynch/screens/home.json is the screen the starter created:

{
"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.

Create .ynch/screens/about.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." } }
] }
]
}
}

A screen can only be reached through a route. In .ynch/navigation.json, add one to routes:

{ "id": "about", "screenId": "about", "label": "About", "parameters": {} }

Add this to the children of the home screen, after the welcome text:

{
"id": "open-about",
"type": "Button",
"props": { "label": "About this app" },
"action": { "type": "navigate", "routeId": "about", "parameters": {} }
}
Terminal window
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.

  • A screen is a tree of components under one Screen.
  • Screens are reached through routes.
  • A Button navigates with an action.

Next: add a tab bar or connect a database.