# Guestbook Example

This capsule shows a shared feed where every signed entry stores author metadata from Lakebed auth.

## What It Shows

- An `entries` table with `body`, `authorId`, `authorName`, and `authorPicture`.
- A shared `entries` query ordered by newest first.
- A `sign` mutation that trims and bounds user input.
- Server-side authorship from `ctx.auth`, not from client-submitted fields.
- A Preact UI using `useAuth`, `useQuery`, `useMutation`, and `<SignInWithGoogle />`.

## Server Pattern

Use shared feeds when every user can read the same rows:

```ts
queries: {
  entries: query((ctx) => ctx.db.entries.orderBy("createdAt", "desc").limit(50).all())
}
```

Still keep writes server-authoritative:

```ts
ctx.db.entries.insert({
  body: trimmed,
  authorId: ctx.auth.userId,
  authorName: ctx.auth.displayName,
  authorPicture: ctx.auth.picture ?? ""
});
```

Do not accept `authorId`, `authorName`, `authorPicture`, or other trusted metadata from the client.

## Run It

Run the checked-in example:

```sh
npx lakebed auth as alice
npx lakebed dev examples/guestbook
```

Open:

```txt
http://localhost:3000
```

To see shared updates from multiple identities, open:

```txt
http://localhost:3000/?lakebed_guest=alice
http://localhost:3000/?lakebed_guest=bob
```

Then inspect state:

```sh
npx lakebed db dump --port 3000
npx lakebed logs --port 3000
```
