# ctx.stickers

Give someone a sticker for their My Fave1 home — a trophy for a win, a badge for a streak, their cat. It lands in Decorate › Stickers with your app’s icon on it, and they stick it wherever they like.

storage

## Calls

`ctx.stickers`

```ts
await ctx.stickers.give({ id, name, image }); // → StickerInfo
await ctx.stickers.list();                     // → StickerInfo[], newest first
await ctx.stickers.delete(id);                 // takes it back, off their home too
ctx.stickers.open();                           // My Fave1 › Decorate › Stickers, in a new tab
```

`StickerInfo`

```ts
{
  id: 'first-win',          // yours — up to 32: lowercase words joined by single dashes
  name: 'First win',        // what they see under it, 1 to 40 characters
  file: '4c1f9a2e-…',       // the picture — one of your ctx.files
  createdAt: '2026-11-14T09:12:40.000Z',
  updatedAt: '2026-11-14T09:12:40.000Z',
}
```

## Give one when they earned it

Draw the sticker on a canvas — or pass a `Blob` or an `ImageBitmap` — and give it. Fave1 fits it inside 512 × 512 and keeps the see-through parts, so draw it on a transparent canvas: a shape with a white edge looks like a real sticker on any wallpaper.

`src/index.ts`

```ts
async function reward(ctx: Ctx) {
  if (!ctx.can('storage')) return; // signed out, or they switched it off

  const c = document.createElement('canvas');
  c.width = c.height = 400;
  const g = c.getContext('2d')!;
  g.fillStyle = '#fff';
  g.beginPath(); g.arc(200, 200, 190, 0, Math.PI * 2); g.fill();     // white edge
  g.fillStyle = '#FFD666';
  g.beginPath(); g.arc(200, 200, 170, 0, Math.PI * 2); g.fill();
  g.fillStyle = '#3b2a12';
  g.font = '900 120px system-ui';
  g.textAlign = 'center'; g.textBaseline = 'middle';
  g.fillText('🏆', 200, 210);

  await ctx.stickers.give({ id: 'first-win', name: 'First win', image: c });
  ctx.ui.render([
    ctx.ui.text('You got a sticker for your My Fave1 home.'),
    ctx.ui.button('See it', { onClick: () => ctx.stickers.open() }),
  ]);
}
```

Give the same `id` again to change it — a new picture, a new name. Where they stuck it stays put. That’s how a sticker can grow with them: a level badge that updates, their pet in today’s outfit.

> **Make it mean something.** A sticker is a reward — for a level, a win, a streak, a goal. Giving one on every visit fills their tray with noise and they’ll stop looking.

## Where it shows up

In My Fave1 › Decorate › Stickers, the first row is **From your apps**: every sticker apps gave them, newest first, each with the giving app’s icon in the corner. They tap one to put it on their home, then drag, turn and size it. They decide whether it goes up at all — giving it doesn’t place it.

It stays theirs until it’s gone: you `delete()` it, they remove your app, or they delete its file in Fave1 Settings › Storage. In any of those cases it comes off their home on its own.

## The picture is one of your files

A sticker’s picture is saved as one of your app’s [files](https://developers.fave1.com/docs/ctx-files.md), so it counts toward their Fave1 storage and `ctx.files.list()` shows it, named `Sticker · <name>`. Deleting that file with `ctx.files.delete()` takes the sticker back. Giving the same `id` again replaces the file — the old one is deleted.

## One permission: storage

Stickers come with `storage`, the permission you declare for [ctx.storage](https://developers.fave1.com/docs/ctx-storage.md) and ctx.files — no new sentence for people to read. Same rules too: someone has to be signed in, it never asks in app mode, and the first time on a site Fave1 asks once in your panel. If you’d rather not ask in the middle of a game, give the sticker in app mode, or only once `ctx.user.granted` is `true`.

## Limits

| What | Limit | Past it |
| --- | --- | --- |
| `stickers` | 24 per person from your app | quota · scope stickers |
| `picture` | Fit in 512 × 512, saved as WebP (PNG on Safari), 1 MB after that | too-large |
| `id` | Up to 32 characters — lowercase letters and digits, words joined by single dashes | invalid |
| `name` | 1 to 40 characters, trimmed | invalid |

## Errors

| Code | What happened | Try |
| --- | --- | --- |
| `signed-out` | Nobody’s signed in to Fave1 here | skip it |
| `denied` | `storage` isn’t in your manifest, or they switched it off | skip it |
| `not-installed` | They haven’t added your app — a sideloaded run | skip it |
| `cancelled` | They chose Not now on this site | give it in app mode |
| `quota` | 24 stickers from your app already (`err.scope` `'stickers'`), or their storage is full (`'account'`) | delete() one |
| `too-large` | The picture you passed is over 25 MB, or still over 1 MB at 512 px | simpler picture |
| `invalid` | A bad id or name, not an image, or a canvas with another site’s picture on it — the browser won’t let anyone read that | fix it |
| `rate` | Too many uploads — the same limits as ctx.files | later |

## While you build

> **DEV builds keep stickers in this browser.** `give()` still fits and saves the picture the same way, so a bad image fails the same — but nothing reaches My Fave1. Switch Data to [My account](https://developers.fave1.com/docs/quickstart.md#dev-account) and it gives to a DEV slot on your account; those don’t show in My Fave1 either. To see the real thing, ship it and earn it.
