context.achievements
ContextDeclare milestones with @achievement in the toolbar’s metadata header.
Call progress(id, total) with the total reached, or unlock(id) when a one-time action succeeds.
The host announces each new unlock in a bottom-left bar on the earning page and keeps it in the collection. The page stays usable and keyboard focus stays where it was. The latest award shows its details and toolbar logo inside a laurel wreath. Earlier awards show their titles above it. Dismiss reveals the previous award.
For an @achievement-series, call increment(seriesId) once per completed action, or increment(seriesId, amount) for a positive whole-number batch such as the words in a translation. It resolves to the shared lifetime total. A new call represents a new event. The host combines events from concurrent tabs.
For a running measurement, call measure(seriesId, value, trigger?) with this mount’s cumulative contribution, starting at zero. Repeating the same reading is safe after a failed write. Send the same value again when idle to clear the saved receipt. Pick one reporting method for each counter. Both methods update the declared store field for display with useStore. The collection formats built-in fields such as faces and words with their units. A metres series shows metric or imperial units, by the region of the browser’s language.
The achievement guide includes a complete header and usage example.
| Signature | context.achievements: Achievements |
|---|---|
| Take it from | const { achievements } = useToolbar(); |
Members
| Member | Type | Description |
|---|---|---|
read(id) | Promise<AchievementProgress> | Read the saved total, target and first unlock time for this milestone. |
progress(id, value) | Promise<AchievementProgress> | Report the total reached so far. Repeats and lower values preserve the highest total. |
measure(series, value, trigger?) | Promise<number> | Report this mount's cumulative contribution to a declared series. Returns the shared lifetime total. |
increment(series, amount?) | Promise<number> | Count one successful action, or a positive whole number of them, toward a lifetime series. |
unlock(id) | Promise<AchievementProgress> | Complete a milestone. The host announces its first unlock once. |
Example
Stamp Book reports a total, reads it back, and unlocks two one-time awards. Run this toolbar from the website Editor’s examples.
// ==BundlewareToolbar==
// @id stamp-book
// @name Stamp Book
// @version 1.0.0
// @description Collect a pair of stamps, publish an edition, and file it in your archive.
// @match <all_urls>
// @achievement pair | Matched Pair | Collect two stamps. | 2
// @achievement edition | First Edition | Publish a stamp edition.
// @achievement archive | In the Archive | File a published edition in your archive.
// @api 1
// ==/BundlewareToolbar==
const { Toolbar, Icon, useState, useToolbar } = Bundleware;
function StampBook() {
const { achievements } = useToolbar();
const [pair, setPair] = useState<BundlewareAPI.AchievementProgress>();
async function collect(total: number) {
setPair(await achievements.progress('pair', total));
}
async function publish() {
await achievements.unlock('edition');
}
async function archive() {
await publish();
await achievements.unlock('archive');
}
return (
<Toolbar icon={Icon.Palette} theme={{ ink: 'steel' }}>
<Toolbar.Button title="One Stamp" onAction={() => collect(1)} />
<Toolbar.Button title="Two Stamps" onAction={() => collect(2)} />
<Toolbar.Button title="Check Stamps" onAction={async () => setPair(await achievements.read('pair'))} />
<Toolbar.Button title="Publish Edition" onAction={publish} />
<Toolbar.Button title="Publish & Archive" onAction={archive} />
{pair && <Toolbar.Status title="Stamps" text={`${pair.value} of ${pair.target}`} />}
</Toolbar>
);
}
Bundleware.defineToolbar(<StampBook />);Availability
| Bundleware | 1.0.1, build 2026.12.02 |
|---|---|
| Extension | Bundled and installed user toolbars share each toolbar’s progress across tabs. |
| Website | The live demo keeps its own collection in the visitor’s browser. |
| Editor | Each sandbox or Preview on Page run starts with a fresh collection. |
Related
| Name | Description |
|---|---|
useToolbar() | Provides the current toolbar’s achievements in its components. |