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.
1. Look at the home screen
Section titled “1. Look at the home screen”.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.
2. Add a second screen
Section titled “2. Add a second screen”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." } } ] } ] }}3. Give it a route
Section titled “3. Give it a route”A screen can only be reached through a route. In .ynch/navigation.json, add one to routes:
{ "id": "about", "screenId": "about", "label": "About", "parameters": {} }4. Add a button on the home screen
Section titled “4. Add a button on the home screen”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": {} }}5. Check and upload
Section titled “5. Check and upload”npx ynch checknpx ynch uploadApprove 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
Section titled “What you learned”- A screen is a tree of components under one
Screen. - Screens are reached through routes.
- A
Buttonnavigates with anaction.
Next: add a tab bar or connect a database.