Lesson 1 of 6
Your first app
Build a scratchpad that remembers what you type, even after you close it. Along the way you'll learn the four things every VibeOS app does.
What you'll build
You'll need
You'll learn
- How to wait for VibeOS to be ready
- How to find your app's private folder
- How to read and write a file
- How to test your app in the IDE
Step 1 — Open the IDE
Start a blank app
Open the VibeOS IDE. On the left is your code (index.html). On the right is a live preview that runs your app with the real VibeOS SDK. Delete the starter code so the editor is empty. New to the IDE? The IDE tour takes two minutes.
Step 2 — Make the page
Add a heading, a text box and a status line
A VibeOS app is an ordinary web page. Paste in this markup inside <body>. The status line will tell you what the app is doing.
<h1>Scratchpad</h1>
<textarea id="pad" placeholder="Start typing. It saves by itself."></textarea>
<div id="status" class="muted">Starting…</div>Want it to look like the finished app? Copy the <style> block from the finished version. Styles always live inside the page, because apps can't load outside files.
Step 3 — Load saved text
Find your private folder and read the file
Every app gets a private folder that only it can see. You don't know its path in advance, so ask: vos.app.getInfo() returns it as sandboxPath. Then vos.fs.readFile(folder, name) reads the file.
function start() {
// 1. Ask VibeOS for this app's private folder.
window.vos.app.getInfo().then(function (info) {
dir = info.sandboxPath;
// 2. Load what was saved last time. null means "first run".
return window.vos.fs.readFile(dir, FILE);
}).then(function (text) {
if (text) pad.value = text;
setStatus("Ready");
}).catch(function (err) {
setStatus("Could not open storage: " + err.message);
});
}null isn't an error
readFile gives you null. That's why the code says if (text).Call start() at the right moment
VibeOS adds window.vos to your page, but sometimes a moment after your code runs. These two lines handle both cases. Put them at the very end of your script, in every app you build.
// 4. The SDK may already be here, or may arrive a moment later.
if (window.vos) start();
else window.addEventListener("vos-ready", start, { once: true });Step 4 — Save as you type
Write the file after a short pause
vos.fs.writeFile(folder, name, text) saves a file, replacing any older copy. Saving on every key press would be wasteful, so wait until the person pauses for 400 ms.
// 3. Save shortly after the user stops typing, not on every key.
pad.addEventListener("input", function () {
if (!dir) return;
setStatus("Saving…");
clearTimeout(timer);
timer = setTimeout(function () {
window.vos.fs.writeFile(dir, FILE, pad.value)
.then(function () { setStatus("Saved"); })
.catch(function (err) { setStatus("Save failed: " + err.message); });
}, 400);
});Step 5 — Name your app
Fill in the app details
Open the Info tab at the top of the IDE. Give the app a name, an emoji icon and a short description. Under permissions, turn on file access and leave the folder lists empty: that means "only my private folder", so people won't be asked anything when they install it.
The IDE turns all this into your app file, called a manifest. You can see it in the Manifest tab. It looks like this:
{
"vibe": 1,
"name": "Scratchpad",
"iconEmoji": "📝",
"iconBg": "linear-gradient(135deg,#10b981,#0ea5e9)",
"description": "A scratchpad that saves as you type, stored privately inside VibeOS.",
"version": "1.0.0",
"width": 520,
"height": 560,
"permissions": {
"read": [],
"write": []
},
"html": "<!doctype html>… the whole app, as one string …"
}Step 6 — Test it
Check it like a reviewer would
Click Files on the right side. You'll see scratchpad.txt inside your app's folder. Click it to see what was saved. Then open the Console tab on the left and talk to the SDK yourself, one line at a time:
const info = await window.vos.app.getInfo()
info.sandboxPath
await window.vos.fs.readFile(info.sandboxPath, "scratchpad.txt")| Check | Why it matters |
|---|---|
| Click Run to restart the app. Does your text come back? | Saving is the first thing reviewers test. |
| Make the preview narrow, then wide. | People resize windows. Layouts should stretch. |
| Is the Console free of red errors? | Errors are the most common reason for change requests. |
Practice
Show a character count
Add a <span id="count"> to the page and update it in the input listener.
Show a solution
pad.addEventListener("input", function () {
document.getElementById("count").textContent = pad.value.length + " characters";
});Add a Clear button
Show a solution
document.getElementById("clear").onclick = function () {
pad.value = "";
window.vos.fs.writeFile(dir, FILE, "").then(function () { setStatus("Cleared"); });
};Recap
- A VibeOS app is one HTML page with its styles and scripts inside it.
- Start your code when window.vos exists, or when the vos-ready event fires.
- vos.app.getInfo().sandboxPath is your app's private folder.
- vos.fs.readFile returns null for a missing file; vos.fs.writeFile saves one.