Sample apps
Small, complete apps explained in everyday words. Pick the one closest to what you want, copy it, and change it.
Each sample app on these pages is small enough to read in one sitting. Each one does a single useful thing, and each one is a real app that has been run against the platform, not a sketch. Copy one and change it. That is quicker and safer than writing the platform parts from memory.
Good to know You do not need to be a programmer to follow along. Every page says what each part does in plain words, and every new word is explained the first time it shows up.
Pick by what you want to do
Words you will see
ProjectDeployBindingcohostly.jsonVisitorThe platform objectHabits every sample follows
These are the same on every page, so once you know them you know all of them.
- It listens on the right door. A web app waits for visitors at a "port", which is like a numbered door. The samples read the number from
PORTand fall back to 3000. The same number goes incohostly.jsonunderhealth.port, so the platform knows which door to knock on after a deploy. - It says which services it uses. If a service is not listed in
cohostly.json, the app cannot use it. A call to an unlisted service fails. - It treats "not yet" as normal. A visitor who is not signed in, a person who has not agreed to share their name, a Google account nobody has connected yet, a question nobody has answered yet: none of these is a crash. The app shows something sensible.
- It is safe to run twice. Some things the platform can send to your app more than once, such as a timed job or an answer to "may I?". The samples remember what they already did, so a repeat does no harm.
- It keeps nothing important on its own disk. Apps sleep, restart and get replaced by new versions. Anything saved in a file can disappear. Things worth keeping go in the small database. See How apps run.
- It never holds a secret in the code. Keys and passwords come from the platform when the app starts. See Secrets.
Before you start any of them
- Install the command line:
npm install -g cohostly(you need Node 20 or later). - Sign in once:
cohostly login. It shows a code to approve in your browser. - Look at the quickstart if you have never deployed anything.
When an app is online, only you can open it at first. The sample pages say when and how to open it wider, using cohostly share.
Where the code comes from
The samples are copies of the example apps in the toolkit repository, under skills/cohostly-app-code/assets/examples/. There is also a script there, scripts/scaffold.sh, that copies one into a new folder for you.