Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@prismicio/client
Advanced tools
The official JavaScript + TypeScript client library for Prismic
@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.
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);
Contentful is another headless CMS that provides a JavaScript client library for fetching and managing content. It offers similar functionalities to @prismicio/client, such as querying content, handling previews, and managing content models. However, Contentful has a different API structure and may offer more advanced features for enterprise use.
Strapi is an open-source headless CMS that allows you to create and manage content APIs. It provides a JavaScript client library for interacting with its API. Strapi is highly customizable and can be self-hosted, offering more control over the CMS environment compared to Prismic.
The official JavaScript + TypeScript client library for Prismic.
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")
npm install @prismicio/client
To discover what's new on this package check out the changelog. For full documentation, visit the official Prismic documentation.
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.
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.
FAQs
The official JavaScript + TypeScript client library for Prismic
We found that @prismicio/client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 26 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.