Build a live notification inbox¶
In about fifteen minutes you will have a web page that shows a notification the moment your server sends it, in every open tab, and a live list of who is online, added with one command.
Pick your server once; every step below follows it.
You need Node 22 or newer, plus your server's toolchain:
1. Install copit¶
curl -fsSL https://raw.githubusercontent.com/huynguyengl99/copit/main/install.sh | bash
copit is the CLI that copies starters and kits into your project, and updates them later. The line above installs it as one standalone binary on macOS and Linux, whatever your server's language.
Other ways to get copit: npm, uv, pip, Windows
On Windows, use npm or pip, or download the binary from the releases.
You use it twice here: to create the app now, and to add a second feature later.
2. Create the starter app¶
You now have a server, a React app in web/, and the notification kit already copied
into both.
3. Start the server¶
The server listens on port 8000. Leave it running.
4. Open the inbox¶
In a second terminal:
Open http://localhost:5173. You see chanx app with an empty notification feed, its status reading open: the page holds a live connection to your server.
5. Send from the page¶
Open the same address in a second browser tab. In either tab, type a title and press Send.
The notification appears in both tabs at once.
6. Send from your terminal¶
Nothing on the sending side needs a WebSocket. Any process that can reach your server can push:
curl -X POST http://localhost:8000/api/notify \
-H 'Content-Type: application/json' -d '{"title": "Build finished"}'
"Build finished" appears in both tabs.
7. Send to one person¶
Each tab connects as the name in Connect as, chris by default. Change one tab to
ann, then:
curl -X POST http://localhost:8000/api/notify \
-H 'Content-Type: application/json' -d '{"title": "Just for Ann", "user": "ann"}'
Only Ann's tab shows it. The server refused to let Chris's tab subscribe to Ann's notifications in the first place.
8. Add a second kit¶
Every feature is one copit command. Add presence, the server half and the browser half
together. The starter already knows where kits come from (its copit.toml), so there is
nothing to set up first:
Two new folders appear: the server kit next to notification, and
web/src/chanx-kit/presence.
9. Mount it¶
List the presence topic next to the notification ones:
In src/app.ts:
In app/consumers.py:
Then regenerate the typed client from the server's schema:
web/src/generated/channels.ts now has a presenceTopic.
10. Show who is here¶
In web/src/App.tsx, next to useNotifications:
import { PresenceRoster, usePresence } from '@/chanx-kit/presence/react';
import '@/chanx-kit/presence/presence.css';
// inside App(), with the same options, so it shares the socket:
const { members } = usePresence(
notifications,
notifications.topics.presenceTopic.with({ scope: 'lobby' }),
{ queryParams: { as: who } },
);
// in the JSX, under the header:
<PresenceRoster members={members} self={who} />
Both tabs now list chris and ann. Close one, and the other drops it.
What you built¶
A server that pushes to the right browser tabs from anywhere, a React inbox that stays typed to the server's own schema, a live roster added with one command, and the code for all of it in your project, yours to edit.
Next¶
- Make it your own project: start a project on your framework, or set up an existing app.
- Build another feature: a chat room with who's online or an AI agent streaming to the page.
- Understand it: how it works.