Building user interactivity on your website without a backend.
content
$type
pub.leaflet.content
pages
0
id
019acb3a-2a27-7119-a11a-eb36e1a82340
$type
pub.leaflet.pages.linearDocument
blocks
0
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
298
byteStart
268
features
0
uri
https://nekomimi.pet/guestbook
$type
pub.leaflet.richtext.facet#link
plaintext
Remember guestbooks? Those little corners of the web where visitors could leave their mark, say hello, or just prove they were there. They were charming. They were personal. And thanks to AT Protocol, they can be even better now. You can sign mine at my website here: https://neko…
1
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
16
byteStart
8
features
0
$type
pub.leaflet.richtext.facet#italic
1
uri
https://tangled.org/nekomimi.pet/cutebook
$type
pub.leaflet.richtext.facet#link
plaintext
I built cutebook, a tiny library that lets you add a guestbook to any website. Visitors sign in with their Bluesky account, leave a message, and that message gets stored in their own data repository. No database on your end. No user accounts to manage. Just two web components and…
2
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
How it works
3
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
73
byteStart
67
features
0
$type
pub.leaflet.richtext.facet#bold
1
uri
https://tangled.org/mary.my.id/atcute
$type
pub.leaflet.richtext.facet#link
1
index
byteEnd
131
byteStart
118
features
0
$type
pub.leaflet.richtext.facet#bold
1
uri
https://constellation.microcosm.blue/
$type
pub.leaflet.richtext.facet#link
plaintext
The magic here comes from two pieces of the AT Protocol ecosystem: atcute for authentication and record creation, and Constellation (part of microcosm) for indexing.
4
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
When someone signs your guestbook, the entry gets written to their personal repository as a record with the type `pet.nkp.guestbook.sign`. It contains their message, a timestamp, and a reference to your DID (your decentralized identifier). That reference is the key.
5
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
Constellation watches for these records across the network. When it sees a guestbook signature pointing to your DID, it indexes it as a "backlink." Your website can then query Constellation asking, "Hey, show me all the guestbook entries that reference me." And just like that, yo…
That's it for setup. The configureGuestbook function initializes the OAuth flow and registers two custom elements that you can now use anywhere in your HTML:
The <guestbook-sign> component handles the entire signing flow. It shows a handle input for users to sign in, redirects them through OAuth, and then presents a message form. When they submit, it creates the record in their repository using atcute's client.
14
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
23
byteStart
4
features
0
$type
pub.leaflet.richtext.facet#code
1
index
byteEnd
154
byteStart
132
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
The <guestbook-display> component fetches entries from Constellation and renders them. It queries the backlinks API, asking for all pet.nkp.guestbook.sign records that reference your DID. For each one, it fetches the full record content and the author's profile, then displays the…
15
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
The OAuth Dance
16
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
42
byteStart
22
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
You'll need to host a client-metadata.json file at a public URL. This is how AT Protocol OAuth identifies your application:
The guestbook signature record is simple. Here's what gets written to a user's repo when they sign:
20
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.code
language
json
plaintext
{
"$type": "pet.nkp.guestbook.sign",
"subject": "did:plc:your-did-here",
"message": "Hello from the AT Protocol!",
"createdAt": "2025-11-28T12:00:00.000Z"
}
syntaxHighlightingTheme
rose-pine
21
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
11
byteStart
4
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
The subject field is an AT identifier pointing to the guestbook owner (you). Constellation indexes this as a backlink, which is what makes the whole thing queryable.
22
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
When the display component loads, it makes a request like:
23
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.code
language
plaintext
plaintext
GET https://constellation.microcosm.blue/xrpc/blue.microcosm.links.getBacklinks
?subject=did:plc:your-did-here
&source=pet.nkp.guestbook.sign:subject
&limit=50
syntaxHighlightingTheme
rose-pine
24
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
Constellation returns a list of records that match, and the component fetches each one to display the message and author info.
The identity resolver is what lets atcute turn a handle like alice.bsky.social into a DID and find the user's PDS. The composite resolver handles both did:plc (most Bluesky users) and did:web (self-hosted identities).
29
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
Starting the Login Flow
30
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
When a user enters their handle and clicks "Sign In," you redirect them to their authorization server:
31
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.code
language
ts-tags
plaintext
async function login(handle: string) {
const authUrl = await createAuthorizationUrl({
target: { type: 'account', identifier: handle },
scope: 'atproto transition:generic',
});
// Give the browser a moment to persist state to localStorage
await new Promise(resolve …
syntaxHighlightingTheme
rose-pine
32
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
26
byteStart
4
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
The createAuthorizationUrl function does the heavy lifting. It resolves the handle to find the user's PDS, discovers their authorization server, generates PKCE codes, stores them in localStorage, and builds the OAuth URL.
33
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
Handling the Callback
34
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
When the user approves your app, they get redirected back to your site with OAuth parameters in the URL hash. You need to catch this and finalize the authorization:
35
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.code
language
ts
plaintext
let agent: OAuthUserAgent | null = null;
async function handleOAuthCallback() {
if (location.hash.length <= 1) return;
const params = new URLSearchParams(location.hash.slice(1));
if (!params.has('state') || (!params.has('code') && !params.has('error'))) {
return;
}…
syntaxHighlightingTheme
rose-pine
36
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
18
byteStart
4
features
0
$type
pub.leaflet.richtext.facet#code
1
index
byteEnd
61
byteStart
45
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
The OAuthUserAgent is now authenticated. Its session.info.sub property contains the user's DID.
37
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
38
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
Creating a Record
39
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
With an authenticated agent, you can write records to the user's repository. Here's how to create a guestbook signature:
40
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.code
language
ts-tags
plaintext
import { Client } from '@atcute/client';
async function signGuestbook(guestbookOwnerDid: string, message: string) {
if (!agent) {
throw new Error('Not logged in');
}
// Create a client using the OAuth agent as the handler
const client = new Client({ handler: agent…
syntaxHighlightingTheme
rose-pine
41
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
66
byteStart
59
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
That's it. The record is now in the user's repository. The subject field points to your DID, which is what Constellation will index as a backlink.
42
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
Querying Constellation
43
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
105
byteStart
72
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
Now for the display side. Constellation exposes an XRPC endpoint called blue.microcosm.links.getBacklinks. You query it with:
44
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.unorderedList
children
0
$type
pub.leaflet.blocks.unorderedList#listItem
content
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
7
byteStart
0
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
subject: The DID you want backlinks for (your DID)
children
1
$type
pub.leaflet.blocks.unorderedList#listItem
content
$type
pub.leaflet.blocks.text
facets
0
index
byteEnd
6
byteStart
0
features
0
$type
pub.leaflet.richtext.facet#code
1
index
byteEnd
97
byteStart
76
features
0
$type
pub.leaflet.richtext.facet#code
plaintext
source: The record type and field path that contains the link, formatted as collection:field.path
The response gives you a list of record locators: the DID of the author, the collection, and the record key. But it doesn't include the actual record content. You need to fetch each one.
47
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.header
level
2
facets
plaintext
Fetching Record Content
48
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
For each backlink, fetch the full record from a PDS. We cannot use the bluesky api as that only indexes bluesky records. We could query each DID's pds, and get records from there, or we could use another excellent microcosm service, slingshot, which does that middleman work for u…
The clever bit is how Constellation and atcute complement each other.
56
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
atcute handles all the OAuth complexity. Resolving handles, discovering authorization servers, PKCE, token exchange, DPoP. It gives you a typed client that can write records to any PDS the user is on.
57
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
Constellation solves the query problem. In AT Protocol, records are stored in individual user repositories. There's no central database you can query. But Constellation watches the firehose and indexes relationships between records and identifiers. When you need to find "all reco…
58
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
Together, they let you build social features without running any backend. The user authenticates, you write a record to their repo, Constellation indexes it, and anyone can query those backlinks. The data lives with the users. Your website is just a view.
59
$type
pub.leaflet.pages.linearDocument#block
block
$type
pub.leaflet.blocks.text
facets
plaintext
The killer thing is that it's so fucking easy. No amount of SaaSy garbage that deploys databases and backends for you can compare to this, plus it's free!