Building an app with Claude Code or another AI assistant? You'll probably need to store data at some point - user preferences, content, application state. With itsalive.co, adding a database is as simple as making a fetch call.
No Setup Required
Unlike traditional databases, there's nothing to configure. No connection strings, no schemas, no migrations. Just start saving and retrieving data.
Saving Data
Use the /_db/ endpoint to store any JSON data under a key:
// Save data for the current user
await fetch('/_db/user-preferences', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
theme: 'dark',
notifications: true,
language: 'en'
})
});
Retrieving Data
Fetch your data back with a GET request:
const response = await fetch('/_db/user-preferences');
const data = await response.json();
console.log(data.theme); // 'dark'
Data Scoping
Data is automatically scoped to the logged-in user. This means:
- User A's "preferences" key is separate from User B's
- Users can only access their own data
- No authentication code needed - it's handled for you
Public vs Private Data
By default, data is private to each user. For public data (like blog posts or products), use the public prefix:
// Save public data (anyone can read)
await fetch('/_db/public/blog-posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify([
{ title: 'My First Post', content: '...' },
{ title: 'Another Post', content: '...' }
])
});
Listing Keys
Need to see what keys exist? List them:
const response = await fetch('/_db/');
const keys = await response.json();
// ['user-preferences', 'saved-items', 'draft-content']
Deleting Data
Remove data with a DELETE request:
await fetch('/_db/old-data', {
method: 'DELETE'
});
Complete Example
Here's a simple todo app that persists data:
<!DOCTYPE html>
<html>
<head>
<title>My Todos</title>
</head>
<body>
<h1>My Todos</h1>
<input type="text" id="newTodo" placeholder="Add a todo...">
<button onclick="addTodo()">Add</button>
<ul id="todoList"></ul>
<script>
let todos = [];
// Load todos on page load
async function loadTodos() {
const res = await fetch('/_db/todos');
if (res.ok) {
todos = await res.json();
render();
}
}
// Save todos to database
async function saveTodos() {
await fetch('/_db/todos', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(todos)
});
}
function addTodo() {
const input = document.getElementById('newTodo');
if (input.value.trim()) {
todos.push({ text: input.value, done: false });
input.value = '';
saveTodos();
render();
}
}
function render() {
const list = document.getElementById('todoList');
list.innerHTML = todos.map((t, i) =>
`<li>${t.text}</li>`
).join('');
}
loadTodos();
</script>
</body>
</html>
Tips
- Keep it simple: Store data as JSON objects or arrays
- Use descriptive keys: "user-settings" is better than "data1"
- Handle errors: Check response.ok before parsing JSON
Next Steps
- Add user login to personalize the experience
- Deploy your app if you haven't already