---
title: "@prismicio/client - v7"
tags: ["latest"]
category: "api-references"
audience: developers
lastUpdated: "2026-01-06T08:09:00.000Z"
---

# Overview

`@prismicio/client` is Prismic's SDK for fetching and working with content.

* Fetch content with a [client](#createclient) and many [query methods](#query-methods).
* Retrieve metadata about a Prismic repository using [repository methods](#repository-methods).
* Migrate content to Prismic using a [write-capable client](#createwriteclient).
* Convert content to other formats using [content helpers](#content-helpers).
* Code confidently knowing all APIs are type-safe with [TypeScript](https://www.typescriptlang.org/).

This page documents all APIs provided by `@prismicio/client`.

# Install

`@prismicio/client` can be installed in any JavaScript project.

```sh
npm install --save @prismicio/client
```

> `@prismicio/client` is installed when bootstrapping a project with `@slicemachine/init`. See the [Next.js](https://prismic.io/docs/nextjs.md), [Nuxt](https://prismic.io/docs/nuxt.md), or [SvelteKit](https://prismic.io/docs/sveltekit.md) guide to learn more.

# API

## `createClient()`

Creates a Prismic client that can fetch content from a Prismic repository.

```ts
const client = createClient(repositoryName, config);
```

> See everything a client can do in [query methods](#query-methods) and [repository methods](#repository-methods).

### Parameters

| Parameter         | Type   | Description                                                            | Default |
| ----------------- | ------ | ---------------------------------------------------------------------- | ------- |
| repositoryName    | string | The repository name from which content is fetched.                     | None    |
| config (optional) | object | Configuration for the client. See [`config` options](#config-options). | None    |

### `config` options

Options that configure content requests. See the `config` parameter in [`createClient()`](#createclient).

```ts {2}
const client = createClient("example-prismic-repo", {
  accessToken: "example-access-token",
});
```

| Property                       | Type                                         | Description                                                                                                                                                                                                                    | Default |
| ------------------------------ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
| accessToken (optional)         | string                                       | The secure token for accessing the API. Only needed if your repository is private.                                                                                                                                             | None    |
| routes (optional)              | Route\[] (see definition below)              | A list of [route resolver](https://prismic.io/docs/route-resolver.md) objects that define how a page's `url` property is resolved.                                                                                             | None    |
| brokenRoute (optional)         | string                                       | The `url` value used for broken link fields. A link is broken when its linked page has been unpublished or deleted.                                                                                                            | None    |
| defaultParams (optional)       | object                                       | Default parameters that will be sent with each query. These parameters can be overridden on each query if needed. See [query parameters](#query-parameters).                                                                   | None    |
| fetchOptions (optional)        | RequestInit                                  | Options provided to the client's `fetch()` on all network requests. These options will be merged with internally required options. They can also be overriden on a per-query basis using the query's `fetchOptions` parameter. | None    |
| documentAPIEndpoint (optional) | string                                       | The full Content API V2 endpoint for the repository. Useful if you are using a proxy.                                                                                                                                          | None    |
| fetch (optional)               | typeof fetch                                 | The function used to make network requests to the Prismic Content API. In environments where a global `fetch` function does not exist, this function must be provided.                                                         | None    |
| ref (optional)                 | string \| (() => string \| Promise\<string>) | The [ref](https://prismic.io/docs/api.md#repository-api-fetch-refs) used to query pages. It can optionally be a function that returns a ref.                                                                                   | None    |

**Route definition:**

| Property             | Type                    | Description                                                                                                                   | Default |
| -------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------- |
| type                 | string                  | The API ID of a page type.                                                                                                    | None    |
| path                 | string                  | The resolved path of the page with optional keywords.                                                                         | None    |
| resolvers (optional) | Record\<string, string> | A map of custom keywords to API IDs of the content relationships in the route's document.                                     | None    |
| uid (optional)       | string                  | A specific UID to which this route is scoped. The route is only defined for the page whose UID matches the given UID.         | None    |
| lang (optional)      | string                  | A specific language to which this route is scoped. The route is only defined for pages whose locale matches the given locale. | None    |

### Return type

A Prismic `Client` that can fetch content from the configured Prismic repository.

See the available [query methods](#query-methods) below.

## `createWriteClient()`

Creates a Prismic client that can write content to a Prismic repository. It includes all methods supported in `createClient()`.

```ts
const client = createWriteClient(repositoryName, config);
```

> **Important**
>
> This client is only used for migrating content to Prismic. See the [migration guide](https://prismic.io/docs/migration.md).

### Parameters

| Parameter      | Type                          | Description                                      | Default                           |
| -------------- | ----------------------------- | ------------------------------------------------ | --------------------------------- |
| repositoryName | string                        | The repository name to which content is written. | None                              |
| config         | object (see definition below) | Configuration for the client.                    | `"https://asset-api.prismic.io/"` |

**Child properties:**

| Property                        | Type   | Description                                                              | Default                           |
| ------------------------------- | ------ | ------------------------------------------------------------------------ | --------------------------------- |
| writeToken                      | string | A Prismic write token that allows for writing content to the repository. | None                              |
| assetAPIEndpoint (optional)     | string | The Prismic Asset API endpoint.                                          | `"https://asset-api.prismic.io/"` |
| migrationAPIEndpoint (optional) | string | The Prismic Migration API endpoint.                                      | `"https://migration.prismic.io/"` |
| ...rest (optional)              | object | See [`config` options](#config-options) for other options.               | None                              |

### Return type

A Prismic `WriteClient` that can write content to the configured Prismic repository.

The client should be used with the [`createMigration()`](#createmigration) function and the [`migrate()`](#migrate) client method.

## `createMigration()`

Creates a `Migration` instance that holds a set of migration procedures to execute, like "create a page" or "create an asset." The migration can be executed with a [write client](#createwriteclient)'s [`migrate()`](#migrate) method.

```ts
const migration = createMigration();
```

> See everything a `Migration` instance can do in [migration methods](#migration-methods).

### Return value

A `Migration` instance that can hold migration procedures.

# Query methods

Fetch content from a Prismic repository using the client's query methods.

The following example fetches all blog posts from the `fr-fr` [locale](https://prismic.io/docs/languages-locales.md) using the [`getAllByType()`](#getallbytype) method.

```ts
const client = createClient("example-prismic-repo");
const blogPosts = await client.getAllByType("blog_post", {
  lang: "fr-fr",
});
```

## Query parameters

All query methods accept optional parameters.

| Property                          | Type                               | Description                                                                                                                                                                  | Default |
| --------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| filters (optional)                | string\[]                          | One or more filters to filter pages for the query.                                                                                                                           | None    |
| graphQuery (optional)             | string                             | Specify which fields to retrieve and what content to retrieve from linked pages. See [GraphQuery](https://prismic.io/docs/fields/content-relationship.md#graphquery-legacy). | None    |
| orderings (optional)              | Ordering\[] (see definition below) | Orders the results by the specified field(s). You can specify as many fields as you want.                                                                                    | `"asc"` |
| lang (optional)                   | string                             | The locale from which to return results. Use `"*"` to fetch content from all locales.                                                                                        | None    |
| page (optional)                   | number                             | The results page number when a query returns multiple pages of results.                                                                                                      | None    |
| pageSize (optional)               | number                             | The maximum number of pages that the API will return for your query.                                                                                                         | None    |
| after (optional)                  | string                             | A page ID. Only pages listed after the page ID are returned. Can be used along with the `orderings` parameter.                                                               | None    |
| accessToken (optional)            | string                             | The secure token for accessing the API. Only needed if your repository is private.                                                                                           | None    |
| brokenRoute (optional)            | string                             | The route populated in the `url` property for broken links. A link is broken when its linked page has been unpublished or deleted.                                           | None    |
| fetchLinks (optional)             | string\[]                          | A list of fields to retrieve from linked pages. Prefer the `graphQuery` option over `fetchLinks`.                                                                            | None    |
| integrationFieldsRef (optional)   | string                             | The ref used to populate integration fields.                                                                                                                                 | None    |
| ref (optional)                    | string                             | The ref used to query pages.                                                                                                                                                 | None    |
| routes (optional)                 | Route\[]                           | Orders the results by the specified field(s). You can specify as many fields as you want. See [`Route`](#route).                                                             | None    |
| fetch (optional, deprecated)      | string\[]                          | Make queries faster by only retrieving the specified fields. Use the `graphQuery` option instead.                                                                            | None    |
| predicates (optional, deprecated) | string\[]                          | Renamed to `filters`.                                                                                                                                                        | None    |

**Ordering definition:**

| Property  | Type            | Description                              | Default |
| --------- | --------------- | ---------------------------------------- | ------- |
| field     | string          | The field used to order results.         | None    |
| direction | "asc" \| "desc" | The order of the sorting for this field. | `"asc"` |

## `get()`

Fetches pages based on the `params` argument. Results are paginated.

```ts
await client.get(params);
```

> **Important**
>
> **This method is rarely used**. Consider using one of the more specific methods, like [`getByUID()`](#getbyuid) and [`getByType()`](#getbytype).

### Parameters

| Parameter         | Type   | Description                                                                                | Default |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ | ------- |
| params (optional) | object | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getFirst()`

Fetches the first page returned based on the `params` argument.

```ts
await client.getFirst(params);
```

> **Important**
>
> **This method is rarely used**. Consider using one of the more specific methods, like [`getByUID()`](#getbyuid) and [`getSingle()`](#getsingle).

### Parameters

| Parameter         | Type   | Description                                                                              | Default |
| ----------------- | ------ | ---------------------------------------------------------------------------------------- | ------- |
| params (optional) | object | Parameters that affect which page is fetched. See [query parameters](#query-parameters). | None    |

### Return value

A `PrismicDocument` if one is found, `null` otherwise.

### Possible errors

* Throws `NotFoundError` if a matching page cannot be found.

## `getByID()`

Fetches a page with a specific ID.

```ts
await client.getByID(id, params);
```

> A page's ID is different from its [UID](https://prismic.io/docs/fields/uid.md). An ID is automatically generated and is made available on a page's `id` property. A UID is provided by content writers in the [Page Builder](https://prismic.io/docs/guides/page-builder.md) and is unique among all pages of its type.

### Parameters

| Parameter         | Type   | Description                                                                              | Default |
| ----------------- | ------ | ---------------------------------------------------------------------------------------- | ------- |
| id                | string | A page ID.                                                                               | None    |
| params (optional) | object | Parameters that affect which page is fetched. See [query parameters](#query-parameters). | None    |

### Return value

A `PrismicDocument` if one is found, `null` otherwise.

### Possible errors

* Throws `NotFoundError` if a matching page cannot be found.

## `getByIDs()`

Fetches pages with specific IDs. Results are paginated.

```ts
await client.getByIDs(ids, params);
```

> A page's ID is different from its [UID](https://prismic.io/docs/fields/uid.md). An ID is automatically generated and is made available on a page's `id` property. A UID is provided by content writers in the [Page Builder](https://prismic.io/docs/guides/page-builder.md) and is unique among all pages of its type.

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| ids               | string\[] | Pages IDs.                                                                                 | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getAllByIDs()`

Fetches pages with specific IDs. This method may make multiple network requests to fetch all matching pages.

```ts
await client.getAllByIDs(ids, params);
```

> A page's ID is different from its [UID](https://prismic.io/docs/fields/uid.md). An ID is automatically generated and is made available on a page's `id` property. A UID is provided by content writers in the [Page Builder](https://prismic.io/docs/guides/page-builder.md) and is unique among all pages of its type.

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| ids               | string\[] | Page IDs.                                                                                  | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

An array of matching `PrismicDocument` pages.

## `getByUID()`

Fetches a page with a specific UID and type.

```ts
await client.getByUID(type, uid, params);
```

> A page's [UID](https://prismic.io/docs/fields/uid.md) is different from its ID. A UID is provided by content writers in the [Page Builder](https://prismic.io/docs/guides/page-builder.md) and is unique among all pages of its type. An ID is automatically generated and is made available on a page's `id` property.

### Parameters

| Parameter         | Type   | Description                                                                              | Default |
| ----------------- | ------ | ---------------------------------------------------------------------------------------- | ------- |
| type              | string | A page type.                                                                             | None    |
| uid               | string | A page UID.                                                                              | None    |
| params (optional) | object | Parameters that affect which page is fetched. See [query parameters](#query-parameters). | None    |

### Return value

A `PrismicDocument` if one is found.

### Possible errors

* Throws `NotFoundError` if a matching page cannot be found.

## `getByUIDs()`

Fetches pages with specific UIDs and a specific type. Results are paginated.

```ts
await client.getByUIDs(type, uids, params);
```

> A page's [UID](https://prismic.io/docs/fields/uid.md) is different from its ID. A UID is provided by content writers in the [Page Builder](https://prismic.io/docs/guides/page-builder.md) and is unique among all page of its type. An ID is automatically generated and is made available on a page's `id` property.

### Parameters

| Parameter         | Type      | Description                                                                              | Default |
| ----------------- | --------- | ---------------------------------------------------------------------------------------- | ------- |
| type              | string    | A page type.                                                                             | None    |
| uids              | string\[] | Page UIDs.                                                                               | None    |
| params (optional) | object    | Parameters that affect which page is fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getAllByUIDs()`

Fetches pages with specific UIDs and a specific type. This method may make multiple network requests to fetch all matching pages.

```ts
await client.getAllByUIDs(type, uids, params);
```

> A page's [UID](https://prismic.io/docs/fields/uid.md) is different from its ID. A UID is provided by content writers in the [Page Builder](https://prismic.io/docs/guides/page-builder.md) and is unique among all pages of its type. An ID is automatically generated and is made available on a page's `id` property.

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| type              | string    | A page type.                                                                               | None    |
| uids              | string\[] | Page UIDs.                                                                                 | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

An array of matching `PrismicDocument` pages.

## `getSingle()`

Fetches a specific [single type](https://prismic.io/docs/content-modeling.md#create-a-page-type) page.

```ts
await client.getSingle(type, params);
```

### Parameters

| Parameter         | Type   | Description                                                                              | Default |
| ----------------- | ------ | ---------------------------------------------------------------------------------------- | ------- |
| type              | string | A single page type.                                                                      | None    |
| params (optional) | object | Parameters that affect which page is fetched. See [query parameters](#query-parameters). | None    |

### Return value

A `PrismicDocument` if one is found, `null` otherwise.

### Possible errors

* Throws `NotFoundError` if a matching page cannot be found.

## `getByType()`

Fetches pages with a specific type. Results are paginated.

```ts
await client.getByType(type, params);
```

### Parameters

| Parameter         | Type   | Description                                                                                | Default |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ | ------- |
| type              | string | A page type.                                                                               | None    |
| params (optional) | object | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getAllByType()`

Fetches pages with a specific type. This method may make multiple network requests to fetch all matching documents.

```ts
await client.getAllByType(type, params);
```

### Parameters

| Parameter         | Type   | Description                                                                                | Default |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ | ------- |
| type              | string | A page type.                                                                               | None    |
| params (optional) | object | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

An array of matching `PrismicDocument` pages.

## `getByTag()`

Fetches pages with a specific tag. Results are paginated.

```ts
await client.getByTag(tag, params);
```

### Parameters

| Parameter         | Type   | Description                                                                                | Default |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ | ------- |
| tag               | string | A page tag.                                                                                | None    |
| params (optional) | object | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getAllByTag()`

Fetches pages with a specific tag. This method may make multiple network requests to fetch all matching documents.

```ts
await client.getAllByTag(tag, params);
```

### Parameters

| Parameter         | Type   | Description                                                                                | Default |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ | ------- |
| tag               | string | A page tag.                                                                                | None    |
| params (optional) | object | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

An array of matching `PrismicDocument` pages.

## `getByEveryTag()`

Fetches pages with every tag from a list of tags. Results are paginated.

```ts
await client.getByEveryTag(tags, params);
```

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| tags              | string\[] | Pages tags.                                                                                | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getAllByEveryTag()`

Fetches pages with every tag from a list of tags. This method may make multiple network requests to fetch all matching pages.

```ts
await client.getAllByEveryTag(tags, params);
```

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| tags              | string\[] | Pages tags.                                                                                | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

An array of matching `PrismicDocument` Pages.

## `getBySomeTags()`

Fetches pages with at least one tag from a list of tags. Results are paginated.

```ts
await client.getBySomeTags(tags, params);
```

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| tags              | string\[] | Pages tags.                                                                                | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

A paginated list of pages.

| Property             | Type               | Description                                      | Default |
| -------------------- | ------------------ | ------------------------------------------------ | ------- |
| results              | PrismicDocument\[] | A paginated list of pages matching the query.    | None    |
| page                 | number             | The page number for the page of results.         | None    |
| total\_pages         | number             | The total number of pages.                       | None    |
| results\_size        | number             | The number of results in the page of results.    | None    |
| results\_per\_page   | number             | The maximum number of results per page.          | None    |
| total\_results\_size | number             | The total number of results within all pages.    | None    |
| next\_page           | string \| null     | The API URL to the next page, if one exists.     | None    |
| prev\_page           | string \| null     | The API URL to the previous page, if one exists. | None    |

## `getAllBySomeTags()`

Fetches pages with at least one tag from a list of tags. This method may make multiple network requests to fetch all matching documents.

```ts
await client.getAllBySomeTags(tags, params);
```

### Parameters

| Parameter         | Type      | Description                                                                                | Default |
| ----------------- | --------- | ------------------------------------------------------------------------------------------ | ------- |
| tags              | string\[] | Pages tags.                                                                                | None    |
| params (optional) | object    | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

An array of matching `PrismicDocument` pages.

## `queryLatestContent()`

Configures the client to query the latest published content. This is the client's default mode.

```ts
client.queryLatestContent();
```

## `queryContentFromReleaseByID()`

Configures the client to query content from a release with a specific ID.

```ts
client.queryContentFromReleaseByID(releaseID);
```

### Parameters

| Parameter | Type   | Description   | Default |
| --------- | ------ | ------------- | ------- |
| releaseID | string | A release ID. | None    |

## `queryContentFromReleaseByLabel()`

Configures the client to query content from a release with a specific label. A release's label is its name shown in the [Page Builder](https://prismic.io/docs/guides/page-builder.md).

```ts
client.queryContentFromReleaseByLabel(releaseLabel);
```

### Parameters

| Parameter    | Type   | Description      | Default |
| ------------ | ------ | ---------------- | ------- |
| releaseLabel | string | A release label. | None    |

## `queryContentFromRef()`

Configures the client to query content from a specific [ref](https://prismic.io/docs/api.md#repository-api-fetch-refs).

```ts
client.queryContentFromRef(ref);
```

### Parameters

| Parameter | Type                                         | Description                                                                                                                                  | Default |
| --------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| ref       | string \| (() => string \| Promise\<string>) | The [ref](https://prismic.io/docs/api.md#repository-api-fetch-refs) used to query pages. It can optionally be a function that returns a ref. | None    |

# Repository methods

Fetch repository metadata using the client's repository methods.

## `getRepository()`

Fetches metadata about the client's Prismic repository.

```ts
await client.getRepository();
```

### Return value

| Property                 | Type                               | Description                                                            | Default |
| ------------------------ | ---------------------------------- | ---------------------------------------------------------------------- | ------- |
| refs                     | Ref\[] (see definition below)      | The repository's active refs.                                          | None    |
| languages                | Language\[] (see definition below) | The repository's enabled languages.                                    | None    |
| types                    | Record\<string, string>            | The repository's content model API IDs mapped to their labels.         | None    |
| integrationFieldsRef     | string \| null                     | The value used to select a content version for integration field data. | None    |
| license                  | string                             | Licensing information for the repository's content.                    | None    |
| oauth\_initiate          | string                             | The URL used to begin the OAuth process for the repository.            | None    |
| oauth\_token             | string                             | The token used for the OAuth process for the repository.               | None    |
| version                  | string                             | The version of the API. You probably don't need this.                  | None    |
| bookmarks (deprecated)   | unknown                            | No longer used.                                                        | None    |
| experiments (deprecated) | unknown                            | No longer used.                                                        | None    |
| forms (deprecated)       | unknown                            | No longer used.                                                        | None    |
| tags (deprecated)        | string\[]                          | Use the [`getTags()`](#gettags) method instead.                        | None    |

**Ref definition:**

| Property               | Type    | Description                                                                                                                                                               | Default |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| id                     | string  | The ref's unique ID.                                                                                                                                                      | None    |
| ref                    | string  | The value used to select a content version.                                                                                                                               | None    |
| label                  | string  | The ref's name. The master ref is always named "Master."                                                                                                                  | None    |
| isMasterRef            | boolean | Determines if the ref is the master ref. The master ref contains the latest published content.                                                                            | None    |
| scheduledAt (optional) | string  | If the ref is associated with a [release](https://prismic.io/docs/releases.md), this value is the timestamp at which the release will be automatically published, if set. | None    |

**Language definition:**

| Property   | Type    | Description                                                           | Default |
| ---------- | ------- | --------------------------------------------------------------------- | ------- |
| id         | string  | The language's unique ID.                                             | None    |
| name       | string  | The language's name.                                                  | None    |
| is\_master | boolean | Determines if the language is the default language of the repository. | None    |

## `getRefs()`

Fetches the repository's active [refs](https://prismic.io/docs/api.md#repository-api-fetch-refs).

```ts
await client.getRefs();
```

### Return value

An array of ref objects:

| Property               | Type    | Description                                                                                                                                                               | Default |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| id                     | string  | The ref's unique ID.                                                                                                                                                      | None    |
| ref                    | string  | The value used to select a content version.                                                                                                                               | None    |
| label                  | string  | The ref's name. The master ref is always named "Master."                                                                                                                  | None    |
| isMasterRef            | boolean | Determines if the ref is the master ref. The master ref contains the latest published content.                                                                            | None    |
| scheduledAt (optional) | string  | If the ref is associated with a [release](https://prismic.io/docs/releases.md), this value is the timestamp at which the release will be automatically published, if set. | None    |

## `getRefByLabel()`

Fetches a ref by its label. A release ref's label is its name shown in the [Page Builder](https://prismic.io/docs/guides/page-builder.md).

```ts
client.getRefByLabel(releaseLabel);
```

### Parameters

| Parameter    | Type   | Description      | Default |
| ------------ | ------ | ---------------- | ------- |
| releaseLabel | string | A release label. | None    |

### Possible errors

* Throws `PrismicError` if a matching release cannot be found.

## `getMasterRef()`

Fetches the repository's master ref.

```ts
client.getMasterRef();
```

## `getReleases()`

Fetches the repository's active releases.

```ts
await client.getReleases();
```

### Return value

An array of ref objects:

| Property               | Type    | Description                                                                                                                                                               | Default |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| id                     | string  | The ref's unique ID.                                                                                                                                                      | None    |
| ref                    | string  | The value used to select a content version.                                                                                                                               | None    |
| label                  | string  | The ref's name. The master ref is always named "Master."                                                                                                                  | None    |
| isMasterRef            | boolean | Determines if the ref is the master ref. The master ref contains the latest published content.                                                                            | None    |
| scheduledAt (optional) | string  | If the ref is associated with a [release](https://prismic.io/docs/releases.md), this value is the timestamp at which the release will be automatically published, if set. | None    |

## `getReleaseByID()`

Fetches a release with a specific ID.

```ts
await client.getReleaseByID(releaseID);
```

### Parameters

| Parameter | Type   | Description   | Default |
| --------- | ------ | ------------- | ------- |
| releaseID | string | A release ID. | None    |

### Return value

| Property               | Type    | Description                                                                                                                                                               | Default |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| id                     | string  | The ref's unique ID.                                                                                                                                                      | None    |
| ref                    | string  | The value used to select a content version.                                                                                                                               | None    |
| label                  | string  | The ref's name. The master ref is always named "Master."                                                                                                                  | None    |
| isMasterRef            | boolean | Determines if the ref is the master ref. The master ref contains the latest published content.                                                                            | None    |
| scheduledAt (optional) | string  | If the ref is associated with a [release](https://prismic.io/docs/releases.md), this value is the timestamp at which the release will be automatically published, if set. | None    |

### Possible errors

* Throws `PrismicError` if a matching release cannot be found.

## `getReleaseByLabel()`

Fetches a release by its label. A release ref's label is its name shown in the [Page Builder](https://prismic.io/docs/guides/page-builder.md).

```ts
await client.getReleaseByLabel(releaseLabel);
```

### Parameters

| Parameter    | Type   | Description      | Default |
| ------------ | ------ | ---------------- | ------- |
| releaseLabel | string | A release label. | None    |

### Return value

| Property               | Type    | Description                                                                                                                                                               | Default |
| ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| id                     | string  | The ref's unique ID.                                                                                                                                                      | None    |
| ref                    | string  | The value used to select a content version.                                                                                                                               | None    |
| label                  | string  | The ref's name. The master ref is always named "Master."                                                                                                                  | None    |
| isMasterRef            | boolean | Determines if the ref is the master ref. The master ref contains the latest published content.                                                                            | None    |
| scheduledAt (optional) | string  | If the ref is associated with a [release](https://prismic.io/docs/releases.md), this value is the timestamp at which the release will be automatically published, if set. | None    |

### Possible errors

* Throws `PrismicError` if a matching release cannot be found.

## `getTags()`

Fetches the repository's page tags.

```ts
client.getTags();
```

### Returns

An array of `string` tags.

## `buildQueryURL()`

Builds a Content API query URL with a set of parameters.

```ts
client.buildQueryURL(params);
```

> **Important**
>
> Prefer using [query methods](#query-methods) over using URLs directly.

### Parameters

| Parameter         | Type   | Description                                                                                | Default |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ | ------- |
| params (optional) | object | Parameters that affect which pages are fetched. See [query parameters](#query-parameters). | None    |

### Return value

The Content API URL as a `string`.

## `resolvePreviewURL()`

Fetches a previewed page's URL using a preview token and page ID. The token and page ID are provided in the URL opened after clicking the Page Builder's [**Preview the page**](https://prismic.io/docs/preview.md) button.

```ts
await client.resolvePreviewURL(params);
```

### Parameters

| Parameter | Type                             | Description                                                | Default |
| --------- | -------------------------------- | ---------------------------------------------------------- | ------- |
| params    | undefined (see definition below) | Parameters that determine how the preview URL is resolved. |  `"/"`  |

**Child parameters:**

| Parameter               | Type                                                             | Description                                                                                                                                                                                                                                          | Default |
| ----------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| previewToken            | string                                                           | The preview token provided by the preview session.                                                                                                                                                                                                   | None    |
| documentID              | string                                                           | The previewed page's ID used to determine the destination URL.                                                                                                                                                                                       | None    |
| defaultURL (optional)   | string                                                           | The URL used if a page URL cannot be resolved.                                                                                                                                                                                                       |  `"/"`  |
| linkResolver (optional) | (field: ContentRelationshipField) => string \| null \| undefined | A [link resolver](https://prismic.io/docs/route-resolver.md#link-resolver) used to convert a content relationship field. If the link resolver returns a value, it takes priority over a [route resolver](https://prismic.io/docs/route-resolver.md). | None    |

### Return value

The previewed page's URL as a `string`, or `defaultURL` if a matching page cannot be found.

## `graphQLFetch()`

A preconfigured `fetch()` function for Prismic's [GraphQL API](https://prismic.io/docs/graphql-technical-reference.md) that can be provided to [GraphQL](https://graphql.org/) clients. It adds the required `prismic-ref` and `Authorization` headers to all requests.

```ts
client.graphQLFetch;
```

> If you are using [Apollo Client](https://www.apollographql.com/client), use the [`apollo-link-prismic`](https://github.com/prismicio/apollo-link-prismic) community package instead. It uses `graphQLFetch()` internally.

## `migrate()`

> **Important**
>
> This method is only available in the [write-capable client](#createwriteclient). Only use `migrate()` in secure environments, like in a local script or a server.

Executes a set of migration procedures added to a `Migration` instance created by [`createMigration()`](#createmigration).

```ts
client.migrate(migration, params);
```

### Parameters

| Parameter | Type                          | Description                                                                       | Default |
| --------- | ----------------------------- | --------------------------------------------------------------------------------- | ------- |
| migration | Migration                     | The `Migration` object to process. See [`createMigration()`](#migration-methods). | None    |
| params    | object (see definition below) | Parameters that affect how the migration is executed.                             | None    |

**Child properties:**

| Property | Type                                          | Description                                               | Default |
| -------- | --------------------------------------------- | --------------------------------------------------------- | ------- |
| reporter | (event: Event) => void (see definition below) | A function called when events occur during the migration. | None    |

### React to migration events

You can react to events during the migration process using the `reporter` option. Each event provides metadata about the event.

The following example logs the event type when an event occurs.

```ts
client.migrate(migration, {
  reporter(event) {
    console.log(event.type);
  },
});
```

The following events are supported:

* `start` - The start of the migration process.
* `end` - The end of the migration process.
* `assets:creating` - An asset is being created.
* `assets:created` - All assets were created.
* `documents:masterLocale` - Fetching the master locale for a page.
* `documents:creating` - A page is being created.
* `documents:created` - All pages were created.
* `documents:updating` - A page is being updated.
* `documents:updated` - All pages were updated.

> See the [source code](https://github.com/prismicio/prismic-client/blob/d5d7edb23a491823766036d582969cdb4faeeba8/src/WriteClient.ts#L76-L119) for a reference of each event's metadata.

# Migration methods

You can migrate content to Prismic using a special [write-capable](#createwriteclient) version of the client.

These methods are available on the `Migration` instance returned by [`createMigration()`](#createmigration).

> See the [migration guide](https://prismic.io/docs/migration.md) for a detailed walkthrough of migrating content to Prismic.

> **Important**
>
> The migration methods only work in environments with [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob), and [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData), including Node.js 20 and later.

## `createAsset()`

Creates a new asset in a `Migration` instance. The asset will not be created in your repository until the migration is executed with [`migrate()`](#migrate).

```ts
migration.createAsset(asset);
migration.createAsset(field);
migration.createAsset(file, filename, params);
```

> Assets are deduplicated in a `Migration` instance. Creating two assets with the same URL, for example, will create one shared asset.

### Parameters

One of the three signatures must be used:

| Parameter | Type  | Description                                                                                      | Default |
| --------- | ----- | ------------------------------------------------------------------------------------------------ | ------- |
| asset     | Asset | An asset object from the [Assets API](https://prismic.io/docs/asset-api-technical-reference.md). | None    |

| Parameter | Type                           | Description                                                                                                                                               | Default |
| --------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| field     | ImageField \| LinkToMediaField | A Prismic [image](https://prismic.io/docs/fields/image.md) or [link to media](https://prismic.io/docs/fields/link-to-media.md) field containing an asset. | None    |

| Parameter | Type                          | Description                                                                                         | Default |
| --------- | ----------------------------- | --------------------------------------------------------------------------------------------------- | ------- |
| file      | Blob \| File \| URL           | Binary data for the asset. It can also be a URL pointing to a hosted asset that will be downloaded. | None    |
| filename  | string                        | The filename shown in the repository's media library.                                               | None    |
| params    | object (see definition below) | Metadata about the image.                                                                           | None    |

**Child parameters:**

| Parameter          | Type      | Description                                                                                                                        | Default |
| ------------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------- | ------- |
| alt (optional)     | string    | [Alternative text](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt) for the image. **Strongly recommended.** | None    |
| notes (optional)   | string    | Notes shown in the repository's media library.                                                                                     | None    |
| credits (optional) | string    | Credits shown in the repository's media library.                                                                                   | None    |
| tags (optional)    | string\[] | Tags for the image.                                                                                                                | None    |

### Return value

A reference to the asset that can be referenced in migration pages. The asset won't be created until the migration is executed with [`migrate()`](#migrate).

## `createDocument()`

Creates a new page in a `Migration` instance. The page will not be created in your repository until the migration is executed with [`migrate()`](#migrate).

```ts
migration.createDocument(document, title, params);
```

### Parameters

| Parameter | Type                          | Description                                                                            | Default |
| --------- | ----------------------------- | -------------------------------------------------------------------------------------- | ------- |
| document  | PrismicDocument               | A Prismic page in API v2 format.                                                       | None    |
| title     | string                        | The title shown in the [Page Builder](https://prismic.io/docs/guides/page-builder.md). | None    |
| params    | object (see definition below) | Metadata about the page.                                                               | None    |

**Child parameters:**

| Parameter              | Type                                                                                                                                                       | Description                                      | Default |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ------- |
| masterLanguageDocument | PrismicMigrationDocument \| PrismicDocument \| ContentRelationshipField \| (() => PrismicMigrationDocument \| PrismicDocument \| ContentRelationshipField) | The page used as the new page's master language. | None    |

### Return value

A reference to the page that can be referenced in other migration pages. The page won't be created until the migration is executed with [`migrate()`](#migrate).

## `updateDocument()`

Updates an existing page in a `Migration` instance. The page will not be updated in your repository until the migration is executed with [`migrate()`](#migrate).

```ts
migration.updateDocument(document, title);
```

### Parameters

| Parameter        | Type            | Description                                                                            | Default                    |
| ---------------- | --------------- | -------------------------------------------------------------------------------------- | -------------------------- |
| document         | PrismicDocument | The Prismic page in API v2 format with updated content.                                | None                       |
| title (optional) | string          | The title shown in the [Page Builder](https://prismic.io/docs/guides/page-builder.md). | The page's existing title. |

### Return value

A reference to the page that can be referenced in other migration pages. The page won't be created until the migration is executed with [`migrate()`](#migrate).

## `createDocumentFromPrismic()`

Creates a new page in a `Migration` instance based on an existing Prismic page. Assets and content relationships will be created and resolved automatically. The page and its assets will not be created in your repository until the migration is executed with [`migrate()`](#migrate).

```ts
migration.createDocumentFromPrismic(document, title);
```

> Use `createDocumentFromPrismic()` to duplicate a page. It also works with pages from external Prismic repositories.

### Parameters

| Parameter | Type            | Description                                                                            | Default |
| --------- | --------------- | -------------------------------------------------------------------------------------- | ------- |
| document  | PrismicDocument | A Prismic page in API v2 format.                                                       | None    |
| title     | string          | The title shown in the [Page Builder](https://prismic.io/docs/guides/page-builder.md). | None    |

### Return value

A reference to the page that can be referenced in other migration pages. The page won't be created until the migration is executed with [`migrate()`](#migrate).

## `getByUID()`

Gets a page with a specific UID and type from within a `Migration` instance. Use this method to retrieve a page that has not yet been migrated using [`migrate()`](#migrate).

```ts
migration.getByUID(type, uid);
```

### Parameters

| Parameter | Type   | Description  | Default |
| --------- | ------ | ------------ | ------- |
| type      | string | A page type. | None    |
| uid       | string | A page UID.  | None    |

### Return value

A `PrismicMigrationDocument` if one is found, `undefined` otherwise.

## `getSingle()`

Gets a specific [single type](https://prismic.io/docs/content-modeling.md#create-a-page-type) page from within a `Migration` instance. Use this method to retrieve a page that has not yet been migrated using [`migrate()`](#migrate).

```ts
migration.getSingle(type);
```

### Parameters

| Parameter | Type   | Description         | Default |
| --------- | ------ | ------------------- | ------- |
| type      | string | A single page type. | None    |

### Return value

A `PrismicMigrationDocument` if one is found, `undefined` otherwise.

# Content helpers

`@prismicio/client` provides helpers that manipulate Prismic content. The helpers can be used throughout your website or in scripts.

Content helpers can be imported directly from `@prismicio/client`:

```ts
import { asDate } from "@prismicio/client";
```

## `asDate()`

Converts a [date](https://prismic.io/docs/fields/date.md) or [timestamp](https://prismic.io/docs/fields/timestamp.md) field to a JavaScript [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date).

```ts
asDate(field);
```

### Parameters

| Parameter | Type                        | Description           | Default |
| --------- | --------------------------- | --------------------- | ------- |
| field     | DateField \| TimestampField | The field to convert. | None    |

### Return value

`field` as a `Date`, or `null` if the field is empty.

## `asLink()`

Converts a [link](https://prismic.io/docs/fields/link.md) field, [link to media](https://prismic.io/docs/fields/link-to-media.md) field, [content relationship](https://prismic.io/docs/fields/content-relationship.md) field, or Prismic page to a URL.

```ts
asLink(fieldOrDocument, params);
```

> **Important**
>
> If you are not using a [link resolver](https://prismic.io/docs/route-resolver.md#link-resolver), use `field.url` or `document.url` instead.

### Parameters

| Parameter       | Type                                                                         | Description                                         | Default |
| --------------- | ---------------------------------------------------------------------------- | --------------------------------------------------- | ------- |
| fieldOrDocument | LinkField \| LinkToMediaField \| ContentRelationshipField \| PrismicDocument | A field or page to convert.                         | None    |
| config          | object (see definition below)                                                | Configuration that affects how a link is converted. | None    |

**Child properties:**

| Property                | Type                                                             | Description                                                                                                                                                                                                                                          | Default |
| ----------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| linkResolver (optional) | (field: ContentRelationshipField) => string \| null \| undefined | A [link resolver](https://prismic.io/docs/route-resolver.md#link-resolver) used to convert a content relationship field. If the link resolver returns a value, it takes priority over a [route resolver](https://prismic.io/docs/route-resolver.md). | None    |

### Return value

The field's or page's URL as a `string`, or `null` if the field is empty.

## `asLinkAttrs()`

Converts a [link](https://prismic.io/docs/fields/link.md) field, [link to media](https://prismic.io/docs/fields/link-to-media.md) field, [content relationship](https://prismic.io/docs/fields/content-relationship.md) field, or Prismic page to a set of link attributes. The attributes are intended to be passed to `<a>` HTML elements.

```ts
asLinkAttrs(fieldOrDocument, params);
```

### Parameters

| Parameter         | Type                                                                         | Description                                         | Default |
| ----------------- | ---------------------------------------------------------------------------- | --------------------------------------------------- | ------- |
| fieldOrDocument   | LinkField \| LinkToMediaField \| ContentRelationshipField \| PrismicDocument | A field or page to convert.                         | None    |
| config (optional) | object (see definition below)                                                | Configuration that affects how a link is converted. | None    |

**Child properties:**

| Property                | Type                                                             | Description                                                                                                                                                                                                                                          | Default |
| ----------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| linkResolver (optional) | (field: ContentRelationshipField) => string \| null \| undefined | A [link resolver](https://prismic.io/docs/route-resolver.md#link-resolver) used to convert a content relationship field. If the link resolver returns a value, it takes priority over a [route resolver](https://prismic.io/docs/route-resolver.md). | None    |
| rel (optional)          | (metadata) => string \| undefined                                | A function that determines the `rel` attribute value. The function is provided metadata about the link.                                                                                                                                              | None    |

### Return value

An object of `<a>` HTML attributes.

| Property | Type                | Description                                                                                      | Default                                                                                                                |
| -------- | ------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| href     | string              | The link's [`href`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href) value.     | None                                                                                                                   |
| target   | \[object Object]    | The link's [`target`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target) value. | `"_blank"` if the field's "Open in new tab" option is checked.                                                         |
| rel      | string \| undefined | The link's [`rel`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel) value.      | [`"noreferrer"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/noreferrer) if the link is external. |

## `asHTML()`

Converts a [rich text](https://prismic.io/docs/fields/rich-text.md) field to HTML. The output can be customized using a set of serialization functions.

```ts
asHTML(field, config);
```

> Use your framework's `<PrismicRichText>` component instead when possible.

### Parameters

| Parameter         | Type                          | Description                                                | Default                                                    |
| ----------------- | ----------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
| field             | RichTextField                 | A field to convert.                                        | None                                                       |
| config (optional) | object (see definition below) | Configuration that affects how the rich text is converted. | Standard HTML elements (e.g. `heading1` becomes a `<h1>`). |

**Child properties:**

| Property                | Type                                                             | Description                                                                                                                                                                                                                                          | Default                                                    |
| ----------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| linkResolver (optional) | (field: ContentRelationshipField) => string \| null \| undefined | A [link resolver](https://prismic.io/docs/route-resolver.md#link-resolver) used to convert a content relationship field. If the link resolver returns a value, it takes priority over a [route resolver](https://prismic.io/docs/route-resolver.md). | None                                                       |
| serializer (optional)   | object \| function                                               | A map of rich text block types to functions that return HTML. A single function can also be provided, but an object is recommended.                                                                                                                  | Standard HTML elements (e.g. `heading1` becomes a `<h1>`). |

### Return value

The rich text field as an HTML `string`.

## `asText()`

Converts a [rich text](https://prismic.io/docs/fields/rich-text.md) field to plain text.

```ts
asText(field, config);
```

### Parameters

| Parameter         | Type                          | Description                                                | Default |
| ----------------- | ----------------------------- | ---------------------------------------------------------- | ------- |
| field             | RichTextField                 | A field to convert.                                        | None    |
| config (optional) | object (see definition below) | Configuration that affects how the rich text is converted. | `" "`   |

**Child properties:**

| Property             | Type   | Description                                   | Default |
| -------------------- | ------ | --------------------------------------------- | ------- |
| separator (optional) | string | The string inserted between rich text blocks. | `" "`   |

### Return value

The rich text field as a plain `string`.

## `asImageSrc()`

Converts an [image](https://prismic.io/docs/fields/image.md) field to an image URL. The image can be transformed using imgix's [Rendering API](https://docs.imgix.com/en-US/apis/rendering/overview).

```ts
asImageSrc(field, transformations);
```

> Prismic serves images from [imgix](https://imgix.com), an image CDN and transforming service. All Prismic plans include support for imgix.

### Parameters

| Parameter                  | Type       | Description                                                                                                                                                | Default |
| -------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| field                      | ImageField | A field to convert.                                                                                                                                        | None    |
| transformations (optional) | object     | imgix transformations to apply. See imgix's [Rendering API](https://docs.imgix.com/en-US/apis/rendering/overview) for a list of supported transformations. | None    |

### Return value

The image field's URL as a `string`.

## `asImageWidthSrcSet()`

Converts an [image](https://prismic.io/docs/fields/image.md) field to a [`srcset`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#srcset) designed for `<img>` HTML elements. The `srcset` uses width descriptors, like `400w` and `600w`.

The image can be transformed using imgix's [Rendering API](https://docs.imgix.com/en-US/apis/rendering/overview).

```ts
asImageWidthSrcSet(field, config);
```

> Prismic serves images from [imgix](https://imgix.com), an image CDN and transforming service. All Prismic plans include support for imgix.

### Parameters

| Parameter         | Type                          | Description                                            | Default                                         |
| ----------------- | ----------------------------- | ------------------------------------------------------ | ----------------------------------------------- |
| field             | ImageField                    | A field to convert.                                    | None                                            |
| config (optional) | object (see definition below) | Configuration that affects how the image is converted. | `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]` |

**Child parameters:**

| Parameter                     | Type                      | Description                                                                                                                                                                                                    | Default                                         |
| ----------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| widths (optional)             | "thumbnails" \| number\[] | The width descriptors to be used in the `srcset`. If `"thumbnails"` is provided, the widths of the image's [responsive views](https://prismic.io/docs/fields/image.md#optional-add-responsive-sizes) are used. | `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]` |
| ...transformations (optional) | object                    | imgix transformations to apply. See imgix's [Rendering API](https://docs.imgix.com/en-US/apis/rendering/overview) for a list of supported transformations.                                                     | None                                            |

### Return value

An object of `<img>` HTML attributes.

| Property | Type   | Description                                                                                         | Default |
| -------- | ------ | --------------------------------------------------------------------------------------------------- | ------- |
| src      | string | The image's [`src`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#src) value.       | None    |
| srcset   | string | The image's [`srcset`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#srcset) value. | None    |

## `asImagePixelDensitySrcSet()`

Converts an [image](https://prismic.io/docs/fields/image.md) field to a [`srcset`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#srcset) designed for `<img>` HTML elements. The `srcset` uses pixel density descriptors, like `1x` and `2x`.

The image can be transformed using imgix's [Rendering API](https://docs.imgix.com/en-US/apis/rendering/overview).

```ts
asImagePixelDensitySrcSet(field, config);
```

> Prismic serves images from [imgix](https://imgix.com), an image CDN and transforming service. All Prismic plans include support for imgix.

### Parameters

| Parameter         | Type                          | Description                                            | Default     |
| ----------------- | ----------------------------- | ------------------------------------------------------ | ----------- |
| field             | ImageField                    | A field to convert.                                    | None        |
| config (optional) | object (see definition below) | Configuration that affects how the image is converted. | `[1, 2, 3]` |

**Child parameters:**

| Parameter                     | Type      | Description                                                                                                                                                | Default     |
| ----------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| pixelDensities (optional)     | number\[] | The pixel density descriptors to be used in the `srcset`.                                                                                                  | `[1, 2, 3]` |
| ...transformations (optional) | object    | imgix transformations to apply. See imgix's [Rendering API](https://docs.imgix.com/en-US/apis/rendering/overview) for a list of supported transformations. | None        |

### Return value

An object of `<img>` HTML attributes.

| Property | Type   | Description                                                                                         | Default |
| -------- | ------ | --------------------------------------------------------------------------------------------------- | ------- |
| src      | string | The image's [`src`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#src) value.       | None    |
| srcset   | string | The image's [`srcset`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#srcset) value. | None    |

## `mapSliceZone()`

Converts slices in a slice zone to objects of your choosing. It is designed to add data, remove unused content, or preprocess content on a server.

```ts
await mapSliceZone(slices, mappers, context);
```

> Think of `mapSliceZone()` as `slices.map()` with a declarative API, correct TypeScript types, and support for async functions.

### Parameters

| Parameter          | Type                                                                             | Description                                                                                                   | Default |
| ------------------ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------- |
| slices             | SliceZone                                                                        | A set of slices to map.                                                                                       | None    |
| mappers            | Record\<string, (args: Metadata) => Promise\<any> \| any> (see definition below) | A map of slice type IDs to mapper functions. The return value of each function becomes the slice's new value. | None    |
| context (optional) | any                                                                              | Arbitrary data provided to each function in `mappers`.                                                        | None    |

**Metadata definition:**

| Parameter | Type      | Description                                        | Default |
| --------- | --------- | -------------------------------------------------- | ------- |
| slice     | Slice     | A slice to map.                                    | None    |
| index     | number    | The index of `slice` in the slice zone.            | None    |
| slices    | SliceZone | The `slices` argument passed to `mapSliceZone()`.  | None    |
| context   | any       | The `context` argument passed to `mapSliceZone()`. | None    |

### Return value

A promise containing the provided slice zone with each slice converted according to the functions in the `mappers` argument.

### Mapping to UI component props

When using the `<SliceZone>` component from [@prismicio/react](https://prismic.io/docs/technical-reference/prismicio-react/v3.md#slicezone), [@prismicio/vue](https://prismic.io/docs/technical-reference/prismicio-vue/v6.md#slicezone), or [@prismicio/svelte](https://prismic.io/docs/technical-reference/prismicio-svelte/v2.md#slicezone), properties returned by the mapper function become the slice component’s props.

The following example shows how `mapSliceZone()` can populate a React component's `slice` and `lang` props.

```tsx
const slices = await mapSliceZone(document.data.slices, {
  current_language: ({ slice }) => {
    // The slice's component will be rendered like:
    // <CurrentLanguage slice={slice} lang={document.lang} />
    return { slice, lang: document.lang };
  },
});

function CurrentLanguage({ slice, lang }) {
  return <p>The current language is: {lang}</p>;
}
```

## `isFilled`

A set of functions that determine if a field has content or not. Each field type has its own function within `isFilled`.

```ts
isFilled.richText(field);
```

The following functions are available:

* `isFilled.color(field)`
* `isFilled.contentRelationship(field)`
* `isFilled.date(field)`
* `isFilled.embed(field)`
* `isFilled.geoPoint(field)`
* `isFilled.group(field)`
* `isFilled.image(field)`
* `isFilled.imageThumbnail(field)`
* `isFilled.integrationField(field)`
* `isFilled.keyText(field)`
* `isFilled.link(field)`
* `isFilled.linkToMedia(field)`
* `isFilled.number(field)`
* `isFilled.richText(field)`
* `isFilled.select(field)`
* `isFilled.table(field)`
* `isFilled.timestamp(field)`
* `isFilled.title(field)`

Fields that are marked as repeatable, such as a [repeatable list of links](https://prismic.io/docs/fields/link.md#optional-make-the-link-field-repeatable), can be checked with `isFilled.repeatable()`.

```ts
isFilled.repeatable(field);
```

> `isFilled.repeatable()` checks if at least one item was added. It does not tell you if an item within the repeatable has content.

Slice zones can also be checked for at least one slice.

```ts
isFilled.sliceZone(slices);
```

### Parameters

| Parameter | Type                               | Description                                                         | Default |
| --------- | ---------------------------------- | ------------------------------------------------------------------- | ------- |
| field     | RichTextField \| ImageField \| ... | A field to check. The field type must match the `isFilled` checker. | None    |

### Return value

`true` if the field has content, `false` otherwise.

# Query filters

You can adjust which pages are returned by [query methods](#query-methods) using filters. `@prismicio/client` provides helpers to write filters.

```ts
import { filter } from "@prismicio/client";
```

Each filter type has its own function within `filter`.

The following example uses the [`not()`](#not) filter to fetch all **Page** pages except the pages with the `home` UID.

```ts
await client.getAllByType("page", {
  filters: [filter.not("my.page.uid", "home")],
});
```

## `at()`

Checks that a field or page metadata property matches a value exactly.

```ts
filter.at(path, value);
```

### Parameters

| Parameter | Type                                             | Description                                                                                  | Default |
| --------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------- | ------- |
| path      | string                                           | A path to a field or page metadata property. See the supported paths below.                  | None    |
| value     | string \| number \| boolean \| Date \| string\[] | The value to compare against. A `string[]` is only allowed when `path` is `"document.tags"`. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"document.type"`
* `"document.tags"`
* `"document.id"`
* `"my.[document-type].uid"`
* `"my.[document-type].[key-text-field]"`
* `"my.[document-type].[select-field]"`
* `"my.[document-type].[number-field]"`
* `"my.[document-type].[date-field]"`
* `"my.[document-type].[boolean-field]"`
* `"my.[document-type].[content-relationship-field]"`

## `not()`

Checks that a field or page metadata property doesn't match a value exactly.

```ts
filter.not(path, value);
```

### Parameters

| Parameter | Type                                             | Description                                                                                  | Default |
| --------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------- | ------- |
| path      | string                                           | A path to a field or page metadata property. See the supported paths below.                  | None    |
| value     | string \| number \| boolean \| Date \| string\[] | The value to compare against. A `string[]` is only allowed when `path` is `"document.tags"`. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"document.type"`
* `"document.tags"`
* `"document.id"`
* `"my.[document-type].uid"`
* `"my.[document-type].[key-text-field]"`
* `"my.[document-type].[select-field]"`
* `"my.[document-type].[number-field]"`
* `"my.[document-type].[date-field]"`
* `"my.[document-type].[boolean-field]"`
* `"my.[document-type].[content-relationship-field]"`

## `any()`

Includes pages with a field or metadata property matching a value from a given list.

```ts
filter.any(path, values);
```

### Parameters

| Parameter | Type                                     | Description                                                                 | Default |
| --------- | ---------------------------------------- | --------------------------------------------------------------------------- | ------- |
| path      | string                                   | A path to a field or page metadata property. See the supported paths below. | None    |
| values    | (string \| number \| boolean \| Date)\[] | Values to compare against.                                                  | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"document.type"`
* `"document.tags"`
* `"document.id"`
* `"my.[document-type].uid"`
* `"my.[document-type].[key-text-field]"`
* `"my.[document-type].[select-field]"`
* `"my.[document-type].[number-field]"`
* `"my.[document-type].[date-field]"`
* `"my.[document-type].[boolean-field]"`
* `"my.[document-type].[content-relationship-field]"`

## `in()`

Includes pages with an ID or UID matching a value from a given list. This filter is much more efficient at that than the [`any()`](#any) filter.

```ts
filter.in(path, values);
```

### Parameters

| Parameter | Type      | Description                                                     | Default |
| --------- | --------- | --------------------------------------------------------------- | ------- |
| path      | string    | A path to an ID or UID property. See the supported paths below. | None    |
| values    | string\[] | IDs or UIDs to compare against.                                 | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"document.id"`
* `"my.[document-type].uid"`

## `fulltext()`

Includes pages with a matching string anywhere in the page. It can also check within a specific [rich text](https://prismic.io/docs/fields/rich-text.md), [text](https://prismic.io/docs/fields/text.md), or [select](https://prismic.io/docs/fields/select.md) field.

```ts
filter.fulltext(path, searchTerm);
```

### Parameters

| Parameter  | Type                 | Description                                                                                | Default |
| ---------- | -------------------- | ------------------------------------------------------------------------------------------ | ------- |
| path       | "document" \| string | A path to a field or `"document"` to search the whole page. See the supported paths below. | None    |
| searchTerm | string               | The search term to find.                                                                   | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"document"`
* `"my.[document-type].uid"`
* `"my.[document-type].[rich-text-field]"`
* `"my.[document-type].[text-field]"`
* `"my.[document-type].[select-field]"`

## `has()`

Includes pages that have a value for a specific field.

```ts
filter.has(path);
```

### Parameters

| Parameter | Type   | Description                                       | Default |
| --------- | ------ | ------------------------------------------------- | ------- |
| path      | string | A path to a field. See the supported paths below. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"my.[document-type].[field]"`

Groups and slices are not supported.

## `missing()`

Includes pages that do not have a value for a specific field. The inverse of [`has()`](#has).

```ts
filter.missing(path);
```

> This filter will restrict the results to the page type provided in `path`.

### Parameters

| Parameter | Type   | Description                                       | Default |
| --------- | ------ | ------------------------------------------------- | ------- |
| path      | string | A path to a field. See the supported paths below. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"my.[document-type].[field]"`

Groups and slices are not supported.

## `similar()`

Includes pages that have similar content to a given page. This filter allows you to build content discovery features, like a "Related posts" section.

```ts
filter.similar(documentID, specificity);
```

### Parameters

| Parameter   | Type   | Description                                                                      | Default |
| ----------- | ------ | -------------------------------------------------------------------------------- | ------- |
| documentID  | string | The ID of the page used to compare other pages against.                          | None    |
| specificity | number | The maximum number of pages that a term may appear in to be considered relevant. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

## `geopointNear()`

Includes pages with a [geopoint](https://prismic.io/docs/fields/geopoint.md) field value near the given coordinates.

```ts
filter.geopointNear(path, latitude, longitude, radius);
```

> Matching pages will be sorted from nearest to farthest from the corrdinates.

### Parameters

| Parameter | Type   | Description                                                                                              | Default |
| --------- | ------ | -------------------------------------------------------------------------------------------------------- | ------- |
| path      | string | A path to a [geopoint](https://prismic.io/docs/fields/geopoint.md) field. See the supported paths below. | None    |
| latitude  | number | The latitude coordinate.                                                                                 | None    |
| longitude | number | The longitude coordinate.                                                                                | None    |
| radius    | number | The search radius in kilometers.                                                                         | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"my.[document-type].[geopoint-field]"`

## `numberLessThan()`

Includes pages with a [number](https://prismic.io/docs/fields/number.md) field value less than a given number.

```ts
filter.numberLessThan(path, number);
```

> Number field values equal to the given number are not included.

### Parameters

| Parameter | Type   | Description                                                                                          | Default |
| --------- | ------ | ---------------------------------------------------------------------------------------------------- | ------- |
| path      | string | A path to a [number](https://prismic.io/docs/fields/number.md) field. See the supported paths below. | None    |
| number    | number | The number to compare.                                                                               | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"my.[document-type].[number-field]"`

## `numberGreaterThan()`

Includes pages with a [number](https://prismic.io/docs/fields/number.md) field value greater than a given number.

```ts
filter.numberGreaterThan(path, number);
```

> Number field values equal to the given number are not included.

### Parameters

| Parameter | Type   | Description                                                                                          | Default |
| --------- | ------ | ---------------------------------------------------------------------------------------------------- | ------- |
| path      | string | A path to a [number](https://prismic.io/docs/fields/number.md) field. See the supported paths below. | None    |
| number    | number | The number to compare.                                                                               | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"my.[document-type].[number-field]"`

## `numberInRange()`

Includes pages with a [number](https://prismic.io/docs/fields/number.md) field value within a given range.

```ts
filter.numberInRange(path, lowerLimit, upperLimit);
```

> Number field values equal to the upper and lower limits are included.

### Parameters

| Parameter  | Type   | Description                                                                                          | Default |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------- | ------- |
| path       | string | A path to a [number](https://prismic.io/docs/fields/number.md) field. See the supported paths below. | None    |
| lowerLimit | number | The lower limit of the range.                                                                        | None    |
| upperLimit | number | The upper limit of the range.                                                                        | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `"my.[document-type].[number-field]"`

## `dateAfter()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property after a given date.

```ts
filter.dateAfter(path, date);
```

### Parameters

| Parameter | Type                     | Description                                                                                                                                                                                                                                                                            | Default |
| --------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| path      | string                   | A path to a field or page metadata property. See the supported paths below.                                                                                                                                                                                                            | None    |
| date      | string \| number \| Date | The date to compare. The value can be an ISO 8601 date or timestamp (e.g. `2002-08-28` or `2002-08-28T15:30:00+0300`), a 13-digit Epoch timestamp (e.g. `1030545000000`), or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateBefore()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property before a given date.

```ts
filter.dateBefore(path, date);
```

### Parameters

| Parameter | Type                     | Description                                                                                                                                                                                                                                                                            | Default |
| --------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| path      | string                   | A path to a field or page metadata property. See the supported paths below.                                                                                                                                                                                                            | None    |
| date      | string \| number \| Date | The date to compare. The value can be an ISO 8601 date or timestamp (e.g. `2002-08-28` or `2002-08-28T15:30:00+0300`), a 13-digit Epoch timestamp (e.g. `1030545000000`), or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object. | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateBetween()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property between given dates.

```ts
filter.dateBetween(path, startDate, endDate);
```

### Parameters

| Parameter | Type                     | Description                                                                                                                                                                                                                                                                                  | Default |
| --------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| path      | string                   | A path to a field or page metadata property. See the supported paths below.                                                                                                                                                                                                                  | None    |
| startDate | string \| number \| Date | The start date to compare. The value can be an ISO 8601 date or timestamp (e.g. `2002-08-28` or `2002-08-28T15:30:00+0300`), a 13-digit Epoch timestamp (e.g. `1030545000000`), or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object. | None    |
| endDate   | string \| number \| Date | The end date to compare. The value can be an ISO 8601 date or timestamp (e.g. `2002-08-28` or `2002-08-28T15:30:00+0300`), a 13-digit Epoch timestamp (e.g. `1030545000000`), or a [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object.   | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateDayOfMonth()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is on a specific day of the month.

```ts
filter.dateDayOfMonth(path, dayOfMonth);
```

### Parameters

| Parameter  | Type   | Description                                                                 | Default |
| ---------- | ------ | --------------------------------------------------------------------------- | ------- |
| path       | string | A path to a field or page metadata property. See the supported paths below. | None    |
| dayOfMonth | number | The day of the month to compare.                                            | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateDayOfMonthAfter()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is after a specific day of the month.

```ts
filter.dateDayOfMonthAfter(path, dayOfMonth);
```

### Parameters

| Parameter  | Type   | Description                                                                 | Default |
| ---------- | ------ | --------------------------------------------------------------------------- | ------- |
| path       | string | A path to a field or page metadata property. See the supported paths below. | None    |
| dayOfMonth | number | The day of the month to compare.                                            | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateDayOfMonthBefore()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is before a specific day of the month.

```ts
filter.dateDayOfMonthBefore(path, dayOfMonth);
```

### Parameters

| Parameter  | Type   | Description                                                                 | Default |
| ---------- | ------ | --------------------------------------------------------------------------- | ------- |
| path       | string | A path to a field or page metadata property. See the supported paths below. | None    |
| dayOfMonth | number | The day of the month to compare.                                            | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateDayOfWeek()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is on a specific day of the week.

```ts
filter.dateDayOfWeek(path, dayOfWeek);
```

### Parameters

| Parameter | Type             | Description                                                                 | Default |
| --------- | ---------------- | --------------------------------------------------------------------------- | ------- |
| path      | string           | A path to a field or page metadata property. See the supported paths below. | None    |
| dayOfWeek | string \| number | The day of the week to compare. See the supported days of the week below.   | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

### Supported days of the week

The following days of the week are supported by this filter:

* `"monday"`, `"mon"`, `1`
* `"tuesday"`, `"tue"`, `2`
* `"wednesday"`, `"wed"`, `3`
* `"thursday"`, `"thu"`, `4`
* `"friday"`, `"fri"`, `5`
* `"saturday"`, `"sat"`, `6`
* `"sunday"`, `"sun"`, `7`

Strings can be capitalized (e.g. `"Monday"`) or all caps (e.g. `"MONDAY"`).

## `dateDayOfWeekAfter()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is after a specific day of the week.

```ts
filter.dateDayOfWeekAfter(path, dayOfWeek);
```

### Parameters

| Parameter | Type             | Description                                                                 | Default |
| --------- | ---------------- | --------------------------------------------------------------------------- | ------- |
| path      | string           | A path to a field or page metadata property. See the supported paths below. | None    |
| dayOfWeek | string \| number | The day of the week to compare. See the supported days of the week below.   | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

### Supported days of the week

The following days of the week are supported by this filter:

* `"monday"`, `"mon"`, `1`
* `"tuesday"`, `"tue"`, `2`
* `"wednesday"`, `"wed"`, `3`
* `"thursday"`, `"thu"`, `4`
* `"friday"`, `"fri"`, `5`
* `"saturday"`, `"sat"`, `6`
* `"sunday"`, `"sun"`, `7`

Strings can be capitalized (e.g. `"Monday"`) or all caps (e.g. `"MONDAY"`).

## `dateDayOfWeekBefore()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is before a specific day of the week.

```ts
filter.dateDayOfWeekBefore(path, dayOfWeek);
```

### Parameters

| Parameter | Type             | Description                                                                 | Default |
| --------- | ---------------- | --------------------------------------------------------------------------- | ------- |
| path      | string           | A path to a field or page metadata property. See the supported paths below. | None    |
| dayOfWeek | string \| number | The day of the week to compare. See the supported days of the week below.   | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

### Supported days of the week

The following days of the week are supported by this filter:

* `"monday"`, `"mon"`, `1`
* `"tuesday"`, `"tue"`, `2`
* `"wednesday"`, `"wed"`, `3`
* `"thursday"`, `"thu"`, `4`
* `"friday"`, `"fri"`, `5`
* `"saturday"`, `"sat"`, `6`
* `"sunday"`, `"sun"`, `7`

Strings can be capitalized (e.g. `"Monday"`) or all caps (e.g. `"MONDAY"`).

## `dateMonth()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is within a specific month.

```ts
filter.dateMonth(path, month);
```

### Parameters

| Parameter | Type             | Description                                                                 | Default |
| --------- | ---------------- | --------------------------------------------------------------------------- | ------- |
| path      | string           | A path to a field or page metadata property. See the supported paths below. | None    |
| month     | string \| number | The month to compare. See the supported months below.                       | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

### Supported months

The following months are supported by this filter:

* `"january"`, `"jan"`, `1`
* `"february"`, `"feb"`, `2`
* `"march"`, `"mar"`, `3`
* `"april"`, `"apr"`, `4`
* `"may"`, `"may"`, `5`
* `"june"`, `"jun"`, `6`
* `"july"`, `"jul"`, `7`
* `"august"`, `"aug"`, `8`
* `"september"`, `"sep"`, `9`
* `"october"`, `"oct"`, `10`
* `"november"`, `"nov"`, `11`
* `"december"`, `"dec"`, `12`

Strings can be capitalized (e.g. `"Monday"`) or all caps (e.g. `"MONDAY"`).

## `dateMonthAfter()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is after a specific month.

```ts
filter.dateMonthAfter(path, month);
```

### Parameters

| Parameter | Type             | Description                                                                 | Default |
| --------- | ---------------- | --------------------------------------------------------------------------- | ------- |
| path      | string           | A path to a field or page metadata property. See the supported paths below. | None    |
| month     | string \| number | The month to compare. See the supported months below.                       | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

### Supported months

The following months are supported by this filter:

* `"january"`, `"jan"`, `1`
* `"february"`, `"feb"`, `2`
* `"march"`, `"mar"`, `3`
* `"april"`, `"apr"`, `4`
* `"may"`, `"may"`, `5`
* `"june"`, `"jun"`, `6`
* `"july"`, `"jul"`, `7`
* `"august"`, `"aug"`, `8`
* `"september"`, `"sep"`, `9`
* `"october"`, `"oct"`, `10`
* `"november"`, `"nov"`, `11`
* `"december"`, `"dec"`, `12`

Strings can be capitalized (e.g. `"Monday"`) or all caps (e.g. `"MONDAY"`).

## `dateMonthBefore()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is before a specific month.

```ts
filter.dateMonthBefore(path, month);
```

### Parameters

| Parameter | Type             | Description                                                                 | Default |
| --------- | ---------------- | --------------------------------------------------------------------------- | ------- |
| path      | string           | A path to a field or page metadata property. See the supported paths below. | None    |
| month     | string \| number | The month to compare. See the supported months below.                       | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

### Supported months

The following months are supported by this filter:

* `"january"`, `"jan"`, `1`
* `"february"`, `"feb"`, `2`
* `"march"`, `"mar"`, `3`
* `"april"`, `"apr"`, `4`
* `"may"`, `"may"`, `5`
* `"june"`, `"jun"`, `6`
* `"july"`, `"jul"`, `7`
* `"august"`, `"aug"`, `8`
* `"september"`, `"sep"`, `9`
* `"october"`, `"oct"`, `10`
* `"november"`, `"nov"`, `11`
* `"december"`, `"dec"`, `12`

Strings can be capitalized (e.g. `"Monday"`) or all caps (e.g. `"MONDAY"`).

## `dateYear()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is within a specific year.

```ts
filter.dateYear(path, year);
```

### Parameters

| Parameter | Type   | Description                                                                 | Default |
| --------- | ------ | --------------------------------------------------------------------------- | ------- |
| path      | string | A path to a field or page metadata property. See the supported paths below. | None    |
| year      | number | The year to compare.                                                        | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateHour()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is within a specific hour.

```ts
filter.dateHour(path, hour);
```

### Parameters

| Parameter | Type   | Description                                                                 | Default |
| --------- | ------ | --------------------------------------------------------------------------- | ------- |
| path      | string | A path to a field or page metadata property. See the supported paths below. | None    |
| hour      | number | The hour to compare.                                                        | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateHourAfter()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is after a specific hour.

```ts
filter.dateHourAfter(path, hour);
```

### Parameters

| Parameter | Type   | Description                                                                 | Default |
| --------- | ------ | --------------------------------------------------------------------------- | ------- |
| path      | string | A path to a field or page metadata property. See the supported paths below. | None    |
| hour      | number | The hour to compare.                                                        | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`

## `dateHourBefore()`

Includes pages with a [date](https://prismic.io/docs/fields/date.md) field, [timestamp](https://prismic.io/docs/fields/timestamp.md) field, or timestamp metadata property that is before a specific hour.

```ts
filter.dateHourBefore(path, hour);
```

### Parameters

| Parameter | Type   | Description                                                                 | Default |
| --------- | ------ | --------------------------------------------------------------------------- | ------- |
| path      | string | A path to a field or page metadata property. See the supported paths below. | None    |
| hour      | number | The hour to compare.                                                        | None    |

### Return value

The filter as a `string`. It can be used in a query method's [`filters` parameter](#query-parameters).

### Supported paths

The following paths are supported by this filter:

* `document.first_publication_date`
* `document.last_publication_date`
* `my.[custom-type].[date-field]`
* `my.[custom-type].[timestamp-field]`
