# index

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

## Namespaces

- [JoyLoyaltyPage](https://devdocs.joy.so/joy-headless-api/sdk-reference/weaverse-hydrogen/root/namespaces/JoyLoyaltyPage/)
- [JoyLoyaltyWidget](https://devdocs.joy.so/joy-headless-api/sdk-reference/weaverse-hydrogen/root/namespaces/JoyLoyaltyWidget/)

## Interfaces

### JoyBlockVisibility

What a block's loader surfaces so its component (and useJoyMemberReveal) can finish the job.

#### Properties

##### eligibility?

```ts
eligibility?: JoyCustomerLoyaltyEligibility;
```

The shop's setting, forwarded so the component knows whether the
post-hydrate member gate applies. Omitted in Studio, which bypasses the
gate on both sides.

##### hidden

```ts
hidden: boolean;
```

The SSR verdict — `true` means render nothing at all.

##### personalized?

```ts
personalized?: boolean;
```

`true` when the verdict is personalized to a logged-in customer. Loaders
that read this field must set `Cache-Control: private, no-store` (via
[JOY_PERSONALIZED_CACHE_CONTROL](#joy_personalized_cache_control) from `@joy-loyalty/hydrogen`) when this is
true, to prevent an intermediate cache (CDN, Oxygen full-page, or shared
layers) from serving a logged-in customer's eligibility to a different
visitor. Omitted in Studio.

***

### JoyConfig

#### Properties

##### apiUrl

```ts
apiUrl: string | null;
```

##### locale?

```ts
locale?: string;
```

##### loginUrl

```ts
loginUrl: string;
```

##### shopDomain?

```ts
shopDomain?: string;
```

##### tokenRoute

```ts
tokenRoute: string;
```

## Type Aliases

### JoyCustomerState

```ts
type JoyCustomerState<T> = 
  | {
  status: "loading";
}
  | {
  status: "guest";
}
  | {
  data: T;
  status: "ready";
}
  | {
  message: string;
  status: "error";
};
```

#### Type Parameters

| Type Parameter |
| -------------- |
| []() `T`       |

## Variables

### DEFAULT_TOKEN_ROUTE

```ts
const DEFAULT_TOKEN_ROUTE: "/api/joy-token" = "/api/joy-token";
```

***

### JOY_PERSONALIZED_CACHE_CONTROL

```ts
const JOY_PERSONALIZED_CACHE_CONTROL: "private, no-store" = "private, no-store";
```

***

### joyComponents

```ts
const joyComponents: HydrogenComponent[];
```

Module-shaped entries (`{default, schema, loader}` — equivalent to
`import * as Block` namespaces) ready to spread into the Weaverse
`components` array.

## Functions

### clearJoyToken()

```ts
function clearJoyToken(): void;
```

#### Returns

`void`

***

### getJoyToken()

```ts
function getJoyToken(options?): Promise<string | null>;
```

#### Parameters

| Parameter  | Type                 |
| ---------- | -------------------- |
| `options?` | `GetJoyTokenOptions` |

#### Returns

`Promise`<`string` | `null`>

***

### isJoyBlockDataPersonalized()

```ts
function isJoyBlockDataPersonalized(data): boolean;
```

Checks whether a Weaverse block loader result carries personalized verdicts
— verdicts scoped to a logged-in customer.

Use this in your route handler to set `Cache-Control: private, no-store`
(via [JOY_PERSONALIZED_CACHE_CONTROL](#joy_personalized_cache_control)) when any Joy block on your page
has personalized content, to prevent intermediate caches (CDN, Oxygen's
full-page cache, or shared layers) from serving one shopper's eligibility
verdict to a different visitor.

#### Parameters

| Parameter | Type                                                                               |
| --------- | ---------------------------------------------------------------------------------- |
| `data`    | \| `Partial`<[`JoyBlockVisibility`](#joyblockvisibility)> \| `null` \| `undefined` |

#### Returns

`boolean`

#### Example

```ts
import {isJoyBlockDataPersonalized, JOY_PERSONALIZED_CACHE_CONTROL} from '@joy-loyalty/weaverse-hydrogen';

export async function loader({context}: Route.LoaderArgs) {
  const visibility = await resolveJoyBlockVisibility(context.weaverse);
  // ... render your page with the visibility data

  if (isJoyBlockDataPersonalized(visibility)) {
    context.cacheControl.set('Cache-Control', JOY_PERSONALIZED_CACHE_CONTROL);
  }
  return json({visibility});
}
```

***

### JoyProvider()

```ts
function JoyProvider(__namedParameters): Element;
```

#### Parameters

| Parameter           | Type                                                                                            |
| ------------------- | ----------------------------------------------------------------------------------------------- |
| `__namedParameters` | `Partial`<`Omit`<[`JoyConfig`](#joyconfig), `"apiUrl"`>> & `JoyProviderCartHandlers` & `object` |

#### Returns

`Element`

***

### useJoyConfig()

```ts
function useJoyConfig(fallback): JoyConfig;
```

#### Parameters

| Parameter              | Type                                                                                                  |
| ---------------------- | ----------------------------------------------------------------------------------------------------- |
| `fallback`             | { `apiUrl`: `string` \| `null`; `locale?`: `string`; `loginUrl`: `string`; `shopDomain?`: `string`; } |
| `fallback.apiUrl`      | `string` \| `null`                                                                                    |
| `fallback.locale?`     | `string`                                                                                              |
| `fallback.loginUrl`    | `string`                                                                                              |
| `fallback.shopDomain?` | `string`                                                                                              |

#### Returns

[`JoyConfig`](#joyconfig)

***

### useJoyCustomer()

```ts
function useJoyCustomer<T>(fetcher, options): JoyCustomerState<T>;
```

#### Type Parameters

| Type Parameter |
| -------------- |
| []() `T`       |

#### Parameters

| Parameter             | Type                                                                                                                                                           |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fetcher`             | (`client`) => `Promise`<`T`>                                                                                                                                   |
| `options`             | { `apiUrl`: `string` \| `null`; `deps?`: readonly `unknown`\[]; `enabled?`: `boolean`; `locale?`: `string`; `shopDomain?`: `string`; `tokenRoute`: `string`; } |
| `options.apiUrl`      | `string` \| `null`                                                                                                                                             |
| `options.deps?`       | readonly `unknown`\[]                                                                                                                                          |
| `options.enabled?`    | `boolean`                                                                                                                                                      |
| `options.locale?`     | `string`                                                                                                                                                       |
| `options.shopDomain?` | `string`                                                                                                                                                       |
| `options.tokenRoute`  | `string`                                                                                                                                                       |

#### Returns

[`JoyCustomerState`](#joycustomerstate)<`T`>
