Skip to main content

Quick Start

We’ll get Cuttlefish running in a Next.js app in 5 minutes.
1

Prerequisites

Before we begin, we’ll need:Node.js 20+ - Required for running the Cuttlefish dev server and our Next.js app.A Next.js app - Don’t have one? Create a new Next.js app:
A local Postgres database - Don’t have one? Run Postgres with Docker:
A database table to query - Starting fresh? Create a sample todos table:
2

Installation

Install Cuttlefish packages:
3

Setup

We’ll wrap our app with CuttlefishProvider in app/layout.tsx:
4

Start the dev server

In a separate terminal, start the Cuttlefish dev server:
We should see: Cuttlefish Engine running on http://localhost:4000
5

Your first live query

The useLiveQuery hook executes a SQL query and automatically updates our component when data changes in the database. It returns data, loading, and error states just like any async hook.Create app/page.tsx:
6

Verify it works

Let’s open our Next.js app in the browser at http://localhost:3000. We should see “My Todos” with our existing todos (or an empty list).Now let’s see live updates in action. Open a new terminal and insert a todo directly into the database:
Watch the browser - the new todo appears instantly, with no page refresh.This is Cuttlefish’s core value: our UI stays synchronized with the database in real-time. Any change to the database - whether from another user, a background job, or a manual SQL command - appears immediately in all connected clients.

Next steps

Congratulations! We’ve built our first live-updating React app with Cuttlefish. Learn the concepts: Explore advanced patterns: API Reference: