What’s happening under the hood
In Level 3, we stored messages in an array in memory:
const vzkazy = [
{ jmeno: "Martin", text: "First message!" },
];
That works great – as long as the server keeps running. But when you stop it (Ctrl+C) and start it again, the array is empty. The messages are gone. Why?
Because RAM (the computer’s memory) is like a whiteboard in a classroom: when you leave, someone wipes it clean. For permanent storage, you need a disk – a file or a database.
Disk vs. memory: a file on disk survives a restart. An array in server.js doesn’t. That’s why big websites use databases – MySQL, PostgreSQL, SQLite. We’ll start with SQLite: a database in a single file, no extra server needed.
Show me: what happens after a restart
- Start the server from the guestbook lesson (
node server.js). - Send a new message through React.
- Stop the server (Ctrl+C) and start it again.
- Refresh the page in your browser – the message is gone.
This isn’t a bug in the code. It’s a property of memory. And now you know why databases exist.
Your turn 💪
- Repeat the experiment above and write down (maybe in notes in your project) exactly what happened.
- Open
server.jsand find the line withconst vzkazy = [...]. Add a comment:// WARNING: this disappears after a server restart! - Think about your own project: what shouldn’t disappear on your school/club/journal website? (schedule? photos? messages?) – list 2–3 things.
Check: You understand the difference between memory (temporary) and disk (permanent). In the next lesson you’ll learn Git – to back up code on disk and online. Then SQLite – to store messages forever.
What to take away from this lesson
- Data in an array in
server.jsonly lives until the server restarts. - Permanent storage = a file or database on disk.
- Level 4 will lead you to Git (code backups) and SQLite (a permanent guestbook).
© 2026 Ing. Martin Polak / AlgoRhino · Content usage terms