Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@prismicio/client

prismicio645.9kApache-2.07.17.3TypeScript support: included

The official JavaScript + TypeScript client library for Prismic

typescript, client, helpers, types, utils, toolbox, cms, prismic, prismic.io

readme

@prismicio/client

npm version npm downloads Github Actions CI Codecov Conventional Commits License

The official JavaScript + TypeScript client library for Prismic.

  • Query content from a Prismic repository.
  • Refines queries using Filters.
  • Automatically query draft content during preview sessions.
  • Built for browser and server usage.
import * as prismic from "@prismicio/client"

// Create a client
const client = prismic.createClient("my-repository")

// Then query for your content
const blogPosts = await client.getAllByType("blog_post")

Install

npm install @prismicio/client

Documentation

To discover what's new on this package check out the changelog. For full documentation, visit the official Prismic documentation.

Contributing

Whether you're helping us fix bugs, improve the docs, or spread the word, we'd love to have you as part of the Prismic developer community!

Asking a question: Open a new topic on our community forum explaining what you want to achieve / your question. Our support team will get back to you shortly.

Reporting a bug: Open an issue explaining your application's setup and the bug you're encountering.

Suggesting an improvement: Open an issue explaining your improvement or feature so we can discuss and learn more.

Submitting code changes: For small fixes, feel free to open a pull request with a description of your changes. For large changes, please first open an issue so we can discuss if and how the changes should be implemented.

For more clarity on this project, check out the detailed CONTRIBUTING.md document.

License

Copyright 2013-2024 Prismic <contact@prismic.io> (https://prismic.io)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

7.17.3 (2025-05-28)

Documentation

Refactor

  • isFilled.contentRelationship function overloads to support strict unions (#384) (cdb4e06)

7.17.2 (2025-04-10)

Bug Fixes

  • omit page from all getAll* method params (#383) (5009087)
  • prevent logging the retry message many times (#382) (c2bcf4b)

Documentation

7.17.1 (2025-03-31)

Chore

  • deps: bump imgix-url-builder (e68e43e)
  • deps: maintain dependencies (f921d26)

7.17.0 (2025-03-19)

Features

Bug Fixes

Chore

7.17.0-alpha.0 (2025-03-18)

Features

  • add TableField to AnyRegularField (6f249d0)
  • support key for table field content (165abef)
  • support table field (#375) (39c66f0)

Bug Fixes

Chore

7.16.1 (2025-02-20)

Features

  • add TableField to AnyRegularField (6f249d0)

Bug Fixes

  • export table field types (a0f3e44)
  • export table field types (2862321)

Chore

  • update prismic-mock dep (361b882)

7.16.0 (2025-02-04)

Features

7.16.0-alpha.1 (2025-01-24)

7.16.0-alpha.0 (2025-01-21)

Features

Chore

  • update types-internal dep (3e20131)

7.15.1 (2025-01-16)

Bug Fixes

7.15.0 (2025-01-15)

Bug Fixes

  • properly update document's title with updateDocument (#373) (fa9ca0d)

7.15.0-alpha.0 (2025-01-14)

7.14.0 (2025-01-09)

Features

Refactor

7.14.0-alpha.2 (2024-12-24)

Features

Refactor

7.13.1 (2024-12-11)

Features

Bug Fixes

  • link inside a repeatable contain a key (#363) (eb32f54)

Chore

7.13.1-alpha.0 (2024-12-11)

Features

Bug Fixes

  • link inside a repeatable contain a key (939cac9)

Chore

7.13.0 (2024-12-05)

Features

7.13.0-alpha.0 (2024-11-28)

Features

  • support repeatable links in models (00f8524)

Chore

  • bump types-internal dep (6a5eb26)

7.12.0 (2024-10-30)

Features

7.11.1 (2024-10-30)

Bug Fixes

  • helpers: add missing dir attribute for right-to-left languages (#357) (b607685)

Chore

  • deps: maintain dependencies (9eb295e)

7.11.0 (2024-09-25)

7.10.0-alpha.0 (2024-09-20)

Chore

  • release: 7.10.0-alpha.0 (c801c12)

7.9.0-alpha.3 (2024-09-10)

Chore

7.9.0-alpha.2 (2024-08-27)

Chore

7.9.0-alpha.1 (2024-08-27)

Features

  • use KeyTextField for link text value definition (1a4c51a)

Chore

  • release: 7.9.0-alpha.1 (d940fcd)
  • remove changelog for alpha (50fc797)

7.9.0-alpha.0 (2024-08-14)

Features

  • add text property to link models (40d0e0b)
  • add text to link value models (8459d75)

Chore

7.10.1 (2024-09-23)

Bug Fixes

  • ensure correct content type is attached to asset's blob (80fe887)

7.10.0 (2024-09-23)

Features

  • add createMigration and createWriteClient (#350) (7dc2950)

7.9.0 (2024-09-17)

Features

Chore

  • deps: maintain lock file (601edd5)

7.8.1 (2024-08-27)

Bug Fixes

  • add missing is_master property on repository type (0289698)

7.8.0 (2024-08-01)

Features

7.7.4 (2024-07-24)

Bug Fixes

  • remove hast-util-whitespace dependency (2d9c098)

7.7.3 (2024-07-23)

Bug Fixes

  • ignore trimmed empty spans (6d1ce03)

7.7.2 (2024-07-23)

Bug Fixes

7.7.1 (2024-07-23)

Bug Fixes

  • support relative image URL (5711f04)

7.7.0 (2024-07-23)

Features

Chore

  • deps: maintain dependencies (24df0e9)

7.6.0 (2024-06-20)

Features

Documentation

7.6.0-alpha.0 (2024-06-05)

Features

7.5.0 (2024-05-08)

Features

  • support groups in a slice's primary section (#338) (0672bcb)

7.5.0-alpha.3 (2024-05-07)

Bug Fixes

  • update @prismicio/types-internal (e75b4c2)

7.4.1 (2024-04-13)

Bug Fixes

Chore

7.5.0-alpha.2 (2024-04-26)

Bug Fixes

7.5.0-alpha.1 (2024-04-18)

Bug Fixes

  • export CustomTypeModelFieldForSlicePrimary (16739f6)

7.5.0-alpha.0 (2024-04-17)

Features

  • support groups in a slice's primary section (98a44fa)

Bug Fixes

  • update @prismicio/types-internal (3ee1b06)

Refactor

Chore

  • release alpha as minor (9bd6355)
  • use @prismicio/types-internal alpha (df8f63d)

7.4.1 (2024-04-13)

Bug Fixes

7.4.0 (2024-03-27)

Features

  • stable mapSliceZone (previously unstable_mapSliceZone) (#336) (b6852a4)

7.3.1 (2023-10-11)

Bug Fixes

  • support expired preview token and repository not found API error (#328) (d098a7f)

7.3.0 (2023-10-09)

Features

  • add @prismicio/client/richtext entry (#318) (fb555fd)
  • helpers: support attribute shorthand for map serializer (#321) (b43557d)
  • support expired and not-found ref API errors (#327) (26d5b0f)
  • support extended media API response (#326) (5e5d057)

7.2.0 (2023-08-25)

Features

  • automatically retry rate-limited requests (#319) (e0c8c49)

7.1.1 (2023-08-11)

Bug Fixes

  • reduce the return type of unstable_mapSliceZone() to only include necessary properties (#308) (d52cdfd)
  • throw NotFoundError when a document cannot be found (#316) (74fce89)

Documentation

  • Updated tags and oauth_token definitions in repository.ts (#311) (cad174d)

Chore

7.1.0 (2023-06-07)

Features

Bug Fixes

  • type PrismicDocument.*_publication_date as TimestampField<"filled"> (#304) (7cce22a)

7.0.1 (2023-05-22)

Bug Fixes

  • properly resolve types when using TypeScript's latest module resolution strategy (#300) (a2b1084)

Documentation

7.0.0 (2023-05-17)

Check out the migration guide for how to migrate to @prismicio/client v7

Bug Fixes

  • update Prismic terms to use the latest language style (#293) (1fce99c)

Documentation

  • update link resolver, route resolver, and rich text serializer names (#297) (a991a6c)

Chore

  • @prismicio/types-internal: upgrade @prismicio/types-internal dependency (#294) (edaa83d)

6.8.0 (2023-05-15)

Features

  • add fetchOptions parameter to control fetch() (#291) (a492a40)

Chore

6.7.3 (2022-12-19)

Chore

6.7.2 (2022-12-19)

Bug Fixes

Chore

7.0.0-alpha.5 (2023-05-16)

⚠ BREAKING CHANGES

  • rename config htmlRichTextSerializer to serializer

Refactor

  • rename config htmlRichTextSerializer to serializer (b4bdf7f)

7.0.0-alpha.4 (2023-05-09)

Features

  • add fetchOptions parameter to control fetch() (#289) (88bb32d)
  • client: warn when non-.cdn endpoints are used #284 (81ab2bf)
  • support Web API Requests containing partial URLs (#286) (f2e8895)

Refactor

  • helpers: standardize helpers interface (#288) (59f84ed)
  • rename predicate tests to filter (3100b3a)

Documentation

  • mark optimize option as [@experimental](https://github.com/experimental) (343534f)
  • wording and style (0801785)

7.0.0-alpha.3 (2023-04-28)

Features

7.0.0-alpha.2 (2023-04-22)

Features

  • export AsLinkAttrsConfig (3957ab5)

7.0.0-alpha.1 (2023-04-20)

⚠ BREAKING CHANGES

  • change LinkResolver's default return type to string | null | undefined

Features

  • add asLinkAttrs() helper (#282) (a520aa4)
  • add getToolbarSrc() helper (#281) (f0e768c)
  • add HTMLRichTextSerializer export (014f15e)
  • change LinkResolver's default return type to string | null | undefined (3e1fc53), closes #273
  • optimize concurrent queries via shared network requests (7b72988)
  • port downstream changes from @prismicio/helpers and @prismicio/types (409a6d6)

Bug Fixes

  • delete fetch job even if the network request rejects (92dd2e7)
  • export helper types from the correct locations (21375d1)

Refactor

  • organize types, errors, and imports (#275) (90245e2)
  • rename HTMLSerializer to HTMLRichTextSerializer (84088d6)
  • rename predicate to filter (6e45c28)
  • replace nullish coalescing with || or ternaries (#280) (d4720ad)
  • use backwards compatible ||= syntax (b021748)

Documentation

Chore

  • add "custom" header to .prettierignore (325505d)
  • deprecate orderings string values, resolves #269 (#279) (25b9019)
  • deps: inline escape-html (530e49b)
  • deps: maintain dependencies (4a25c66)
  • deps: update all dependencies (0b0eaee)
  • update .prettierrc import order (74ddbe9)
  • update LICENSE (d94a9e8)

7.0.0-alpha.0 (2022-10-14)

Bug Fixes

  • refactor ImageField for better isFilled.image() compatibility (44369fa)

Chore

  • merge helpers and types, remove deprecated APIs (3201188)
  • remove deprecated APIs (610ddbc)
  • update .github (9600113)

Documentation

Refactor

6.7.1 (2022-09-08)

Bug Fixes

  • widen AbortSignal for greater support of fetch implementations (#263) (70a2eb4)

6.7.0 (2022-08-23)

Features

  • support Route Resolver uid, lang, and brokenRoute options (#258) (22f01c6)

Chore

6.6.4 (2022-08-06)

Chore

6.6.3 (2022-07-26)

Chore

6.6.2 (2022-07-21)

Bug Fixes

  • adjust AbortSignalLike to support native AbortSignal (#250) (62fdae1)

Refactor

  • optimize getFirst() and dependent methods (#249) (ed06cec)

6.6.1 (2022-06-22)

Bug Fixes

  • restore previous explicit document type parameter handling (fixes #246) (#247) (6a33564)

6.6.0 (2022-06-17)

Features

  • declare document TypeScript types in createClient() (#238) (92d8f84)

Bug Fixes

  • resolve issue where getTags() returned an empty array for secured repositories (#245) (b073edc)

Chore

  • deps: upgrade dependencies (ed571d7)

6.5.1 (2022-05-31)

Bug Fixes

  • correctly detect HTTP requests with parsed queries (#244) (d014bc8)

6.5.0 (2022-05-26)

Features

  • accept Web API Request object in enableAutoPreviewsFromReq() (#240) (66e01b9)

Bug Fixes

Chore

  • deps: upgrade dependencies (c3bd66c)
  • remove reverted CHANGELOG entry (f93af08)

6.4.3 (2022-04-15)

Bug Fixes

  • add limit to all getAll*() methods (fixes #233) (#234) (7d3e4c3)
  • optimize pageSize when a limit less than pageSize is given (#236) (3bec394)

Chore

6.4.2 (2022-03-23)

Bug Fixes

  • support boolean and dates in basic predicates, closes #229 (f15f606)

Documentation

  • update with-express example to use a per-request client (#228) (edc8280)

Chore

6.4.1 (2022-03-10)

Bug Fixes

  • cache-bust GraphQL requests made with graphQLFetch() (#227) (894e7a8)

6.4.0 (2022-03-10)

Features

  • rename graphqlFetch() to graphQLFetch() (c1651ba)

Bug Fixes

  • return default URL resolvePreviewURL() does not resolve a string URL (#226) (8b5a689)
  • use pageSize from defaultParams if given when calling dangerouslyGetAll() (0787631)

6.3.0 (2022-02-16)

Features

  • add getRepositoryEndpoint(), getRepositoryName(), isRepositoryName(), isRepositoryEndpoint(); deprecate getEndpoint() (#222) (27bf0ee)
  • support providing a repository name to createClient() in place of an API endpoint (#224) (8c88382)

Chore

6.2.0 (2022-02-04)

Features

  • support abortable requests via AbortController (#221) (5891a83)

Bug Fixes

  • minify GraphQL queries by removing whitespace (#219) (96cad0b)
  • resolve 'document.tags' expected a [list] of 'string' literals error when using tag methods with a single tag (50c78f7)

Documentation

  • fix caching example by using .clone() method (#218) (52b455c)
  • remove version-specific docs link (b141ba7)

Chore

  • deps: update dependencies (5452f87)

Refactor

  • remove type-fest dependency (f1d8124)

6.1.1 (2022-01-28)

Chore

  • deps: update dependencies (d35e2da)
  • support React Native's Metro bundler (9c5a38b)

6.1.0 (2022-01-18)

Features

  • add getGraphQLEndpoint and Client.prototype.graphqlFetch (9b5a126)

Bug Fixes

  • resolve previewed document URL any language (#208) (a7504be)

Refactor

  • simplify graphqlFetch by unsupporting RequestInfo and RequestInit (580c4d5)

Documentation

  • add TSDoc to Client.prototype.graphqlFetch (a883f7e)
  • fix links (144b6bd)

Chore

6.0.0 (2022-01-05)

Check out the migration guide for how to migrate to @prismicio/client v6

6.0.0-beta.5 (2021-12-21)

Features

  • ensure Prismic Rest API V2 endpoint is used (#203) (18faf65)
  • throw NotFoundError if repository does not exist (bf7b862)

Documentation

  • update README links [skip ci] (298e062)

Chore

  • deps: update dependencies (3c8414d)

6.0.0-beta.4 (2021-12-03)

Bug Fixes

  • add predicate aliases for smoother upgrade path (4a1f49c)

Chore

  • deps: maintain dependencies (6250df3)

6.0.0-beta.3 (2021-11-09)

Features

  • throttle getAll* methods and rename getAll to dangerouslyGetAll (#193) (4efdfa0)

6.0.0-beta.2 (2021-10-30)

Bug Fixes

  • revert to providing access token via URL parameter (7a5140e)

6.0.0-beta.1 (2021-10-25)

Features

  • add getBySomeTags, rename getByTags to getByEveryTag (#194) (37385dc)
  • extend all custom errors from PrismicError (c4be6ce)
  • use authorization header for access token (#192) (42af240)

Bug Fixes

  • on getAll methods, use MAX_PAGE_SIZE when pageSize param is falsey (#195) (46b638a)

Chore

  • deps: update dependencies (e7dbd7f)
  • mark package as side effect free (dc02db7)

Refactor

6.0.0-beta.0 (2021-09-29)

Chore

  • deps: maintain dependencies (312ce48)
  • update template config (8dbc214)

6.0.0-alpha.15 (2021-09-14)

Chore

  • update @prismicio/types and @prismicio/helpers (c4e00a1)

6.0.0-alpha.14 (2021-09-14)

Chore

6.0.0-alpha.13 (2021-09-10)

Features

  • add getByUIDs and getAllByUIDs (52a8cc9), closes #191

6.0.0-alpha.12 (2021-09-09)

Features

  • use API types from @prismicio/types (632c2ae)

Bug Fixes

6.0.0-alpha.11 (2021-08-24)

Features

  • provide routes as top-level client options (69f2002)

Chore

6.0.0-alpha.10 (2021-08-19)

Chore

6.0.0-alpha.9 (2021-08-17)

Bug Fixes

  • allow optional Link Resolver in resolvePreviewURL (4321921), closes #183
  • mark resolvers as optional in Routes (d84658a)
  • use "main" as primary branch (c4c02e6)

Chore

  • revert previous commit (a0cf5cb)
  • update dotfiles per standard template (5f4dee0)
  • update pull request template (f618d62)

6.0.0-alpha.8 (2021-07-06)

Bug Fixes

  • support unauthorized repository response (022d278)
  • use access_token URL parameter over Authorization header (#182) (4c44109)

Chore

  • deps: update examples dependencies (1c8f2b2)

6.0.0-alpha.7 (2021-07-03)

Bug Fixes

  • use in predicate for getByIDs (fc522a2)

6.0.0-alpha.6 (2021-07-03)

Chore

6.0.0-alpha.5 (2021-06-27)

Bug Fixes

  • use @prismicio/helpers for resolvePreviewURL (2db45d2)

5.1.0 (2021-06-11)

6.0.0-alpha.4 (2021-06-23)

Bug Fixes

  • support global fetch if provided explicitly (d22ae21)

6.0.0-alpha.3 (2021-06-23)

Features

  • support Route Resolver with routes param (063b5ee)

Bug Fixes

  • resolve issue using global fetch (83c6290), closes #180
  • throw if an invalid fetch function is given (ec01c59)

Refactor

  • simplify SimpleTTLCache and add internal docs (f255a27)

6.0.0-alpha.2 (2021-06-11)

Features

  • add wrapper errors (3dfba0f), closes #177
  • return API error message on failed requests (8de2873)

Chore

6.0.0-alpha.1 (2021-06-07)

Features

  • [wip] cache master ref for a short period (b73a7d0)
  • support cached refs for releases (7a46513)

Bug Fixes

  • use cjs export to support non-esm (63219e8)

Chore

  • add test dir format script (e4594f5)

Documentation

5.0.0 (2021-05-27)

Chore

6.0.0-alpha.0 (2021-05-27)

5.0.0-alpha.1 (2021-05-27)

Chore

5.0.0-alpha.0 (2021-05-27)

Features

  • add "query from" methods and replace ref with release (7d894a5)
  • add getAllByIDs (297a70c)
  • add getTags (164c8d5)
  • add initial client (ee886bd)
  • add release-specific methods (wip) [skip ci] (4f66405)
  • add resolvePreviewUrl (53ed409)
  • export HttpRequestLike (96f1e1e)
  • export predicates under root package (18d742c)
  • expose HTTPError (fdf370a)
  • restore form type (c38e067)
  • restore ref methods and scope release methods (1ff8f72)
  • use normalized HTTPError (0eb9fab)

Bug Fixes

  • asc orderings direction should not be included in query (46431fd)
  • clone responses for better cache support (67ef2ba)
  • correct typings and predicate generation fn (c81da44)
  • export types using export type (a1fad4a)
  • getByIds should return paginated results (fb94561)
  • ignore nullish ordering param (51e53b7)
  • use correct uid predicate for getByUID (5735d28)
  • widen types of fetch-related APIs (412205b)

Documentation

Refactor

  • assume the cookie store is always a string (5d563b0)
  • client (f0c5206)
  • explicitly export types (b5b34fe)
  • export all in root (2bdfd3f)
  • internal predicate fns for readability (731a444)
  • remove ref methods (a333921)
  • remove unnecessary abstraction (d976a11)
  • revert tags refactor (0240a18)
  • share code among tags and ref fns (5c9e7ea)
  • share fetch types (a91a6c3)
  • use @prismicio/types where possible (bb2b514)

Chore