Getting Started
Your first DeltaBase app in 5 minutes
Let’s get you up and running with DeltaBase. No theory. No marketing speak. Just a working event-sourced app in 5 minutes.
What you need
Section titled “What you need”- Node.js 16+ (you probably have this)
- An API key (we’ll give you one)
- 5 minutes
Get your API key
Section titled “Get your API key”During early access, join our Discord and ask for an API key: https://discord.gg/nibbio
We’ll get you set up immediately. No forms, no sales calls.
Create your project
Section titled “Create your project”mkdir deltabase-quickstartcd deltabase-quickstartnpm init -ynpm install @delta-base/server
Write some code
Section titled “Write some code”Create index.js
:
import { DeltaBase } from '@delta-base/server';
const deltabase = new DeltaBase({ apiKey: 'your-api-key-here' // Replace with your actual key});
const eventStore = deltabase.getEventStore('quickstart');
async function main() { console.log('Creating your first event...');
// Append an event await eventStore.appendToStream('user-123', [ { type: 'user.registered', data: { email: 'john@example.com', name: 'John Doe' } } ]);
console.log('Event created! Reading it back...');
// Read the event const events = await eventStore.readStream('user-123'); console.log('Events:', events);
console.log('Done! You just did event sourcing.');}
main().catch(console.error);
Run it
Section titled “Run it”node index.js
You should see:
Creating your first event...Event created! Reading it back...Events: [ { streamId: 'user-123', type: 'user.registered', data: { email: 'john@example.com', name: 'John Doe' }, // ... other event metadata }]Done! You just did event sourcing.
What just happened?
Section titled “What just happened?”- You created an event -
user.registered
with some data - DeltaBase stored it - In a stream called
user-123
- You read it back - From the same stream
That’s event sourcing. Events go in, events come out. Everything else is just details.
Try some more
Section titled “Try some more”Add another event to the same stream:
// Add this to your main() function, before reading eventsawait eventStore.appendToStream('user-123', [ { type: 'user.email_changed', data: { oldEmail: 'john@example.com', newEmail: 'john.doe@example.com' } }]);
Run it again. You’ll see both events in order. That’s your audit trail.
Build something real
Section titled “Build something real”This was just the basics. For a real application, check out:
- Building Your First App - Complete todo app tutorial
- Set Up Real-time Updates - Make it reactive
- Handle Concurrency - Deal with conflicts
What’s next?
Section titled “What’s next?”You just stored your first events. Now you can:
- Query events across streams
- Subscribe to real-time updates
- Build views from events
- Handle complex business logic
Event sourcing isn’t scary. It’s just a different way of thinking about data. And once you get it, you’ll wonder how you ever built apps without it.