Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prismicio/client

Package Overview
Dependencies
Maintainers
26
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/client

The official JavaScript + TypeScript client library for Prismic

  • 7.13.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
26
Created

What is @prismicio/client?

@prismicio/client is an official JavaScript client library for Prismic, a headless CMS. It allows developers to easily query and fetch content from Prismic repositories, manage content models, and handle previews. The package is designed to work seamlessly with modern JavaScript frameworks and libraries.

What are @prismicio/client's main functionalities?

Initialize the Client

This feature allows you to initialize the Prismic client with your repository name and access token. This is the first step to interact with your Prismic content.

const prismic = require('@prismicio/client');
const client = prismic.createClient('your-repo-name', { accessToken: 'your-access-token' });

Fetch All Documents

This feature allows you to fetch all documents from your Prismic repository. It returns an array of documents that you can then manipulate or display in your application.

const documents = await client.getAll();
console.log(documents);

Query by Type

This feature allows you to query documents by their type. For example, you can fetch all documents of type 'blog_post'.

const blogPosts = await client.getByType('blog_post');
console.log(blogPosts);

Fetch a Single Document by ID

This feature allows you to fetch a single document by its ID. This is useful when you need to retrieve specific content based on its unique identifier.

const document = await client.getByID('document-id');
console.log(document);

Handle Previews

This feature allows you to handle content previews. It resolves the preview token and document ID to fetch the preview content, which is useful for previewing unpublished changes.

const previewData = await client.getPreviewResolver(token, documentId).resolve(linkResolver, '/');
console.log(previewData);

Other packages similar to @prismicio/client

Keywords

FAQs

Package last updated on 11 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc