# lib/points

> Source: https://devdocs.joy.so/joy-headless-api/sdk-reference/hydrogen/lib/points/ · Last updated: 2026-11-24

## Variables

### DEFAULT_POINTS_LABEL

```ts
const DEFAULT_POINTS_LABEL: "points" = 'points';
```

The `defaultValue` of every block's "Points label" input, so
[resolvePointsLabel](#resolvepointslabel) compares against one value rather than a literal
repeated per block. `test/schema.test.ts` pins every block's default to it —
a block that drifts would silently stop reading the shop's own point name.

***

### POINTS_LABEL_HELP

```ts
const POINTS_LABEL_HELP: "Leave it as it is to use your shop’s own point name from Joy, singular or plural to match the number." = 'Leave it as it is to use your shop’s own point name from Joy, singular or plural to match the number.';
```

Trailing sentence of every block's "Points label" help text. The rule below
is invisible in Studio otherwise — a merchant who leaves the field alone is
choosing the shop's own wording without being told so.

## Functions

### formatPointsNumber()

```ts
function formatPointsNumber(value, locale?): string;
```

A point count written the way the shopper's locale writes it — "1,500" in
en, "1.500" in de.

`locale` is Hydrogen's, threaded down from the block's loader, which is the
point: it is the SAME value server-side and client-side, so an SSR'd number
and its hydrated re-render agree. Never call `toLocaleString()` with no
argument here — the runtime default is the Oxygen worker's on the server and
the shopper's browser setting on the client, i.e. a hydration mismatch by
construction. A block whose loader surfaced no locale (Hydrogen exposes none)
therefore keeps a fixed tag rather than falling through to that default.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `value`   | `number` |
| `locale?` | `string` |

#### Returns

`string`

***

### resolvePointsLabel()

```ts
function resolvePointsLabel(
   count, 
   setting, 
   shopLabel?
): string;
```

The word to print after `count` — "1 point" / "2 points".

Two branches, and deliberately NO second Studio setting (eight blocks × two
label inputs is worse than the problem it solves):

- the merchant typed their own label ⇒ it is used verbatim for both counts.
  That is an explicit display choice ("stars", "crowns"), and inventing its
  plural would be guessing at grammar for a word we were handed, not told.
- the label is still the schema default ⇒ the shop's own
  `pointLabel.singular`/`.plural` from `/shop-config`, picked by the number.
  Merchants already configure that pair in the Joy admin, so this is what
  JoyBlocks prints and
  what the Liquid theme block prints — that block has no label setting at
  all, which is why the Weaverse one must not grow a second.
- no pair (the `/shop-config` call failed) ⇒ the setting, exactly as before.

Singular at ±1 matches the Joy backend's rule: a −1 spend is still one
point, and 0 is plural.

#### Parameters

| Parameter    | Type                   |
| ------------ | ---------------------- |
| `count`      | `number`               |
| `setting`    | `string`               |
| `shopLabel?` | `PointLabel` \| `null` |

#### Returns

`string`
