prismic-javascript | Official JavaScript TypeScript client library | Frontend Framework library
kandi X-RAY | prismic-javascript Summary
kandi X-RAY | prismic-javascript Summary
Official JavaScript + TypeScript client library for Prismic
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of prismic-javascript
prismic-javascript Key Features
prismic-javascript Examples and Code Snippets
data(){
return{
loading: true
}
},
async asyncData(context) {
try{
const res = await context.app.$prismic.api.query(context.app.$prismic.predicate
Community Discussions
Trending Discussions on prismic-javascript
QUESTION
Cant find a distinctive difference on their docs so asking here.
prismic-javascript or @prismicio/client or prismic-reactjs or prismic-dom They all are npm packages. Can someone explain the 4 separate packages and when to use one over the other.
My assumptions.
- prismic-javascript is for connecting directly to the v2 api.
- @prismicio/client is the same package as prismic-javascript. Still confused about this.
- prismic-reactjs is just react components that you can pass data to from prismic-javascript api results.
- prismic-dom is used for plain vanilla JavaScript projects to render dom elements that you pass data to from prismic-javascript api results.
Am I correct with the above assumptions ?
...ANSWER
Answered 2021-Mar-15 at 19:05me, thanks for the question.
prismic-javascript is the old version, where @prismicio/client is version 4 of the library. I definitely see how that's confusing, I'm working on getting the references cleaned up so that's more straightforward.
prismic-dom contains helpers for things like rendering "Rich Text" fields to the DOM. They come from the API as JSON, so you need something like this to turn it into HTML.
prismic-reactjs is similar to prismic-dom, but turns Rich Text fields into JSX to work with React projects.
So if you're working on a vanilla JavaScript site, you'll use @prismicio/client + prismic-dom. If you're working on a React app, you'll use @prismicio/client + prismic-reactjs.
QUESTION
I'm in the middle of building a next.js app, and I need to make a request for the navigation content to my Prismic
API server-side, get the results, and pass them to my Header
component so that I can have a persistent navigation menu. I don't want to include the header in every page component, nor do I want to have to query the document in every page. Is there a way that I'm able to access getServerSideProps
, getStaticProps
, or getInitialProps
within my _app.js
so that I can have that persistent nav? Here is my _app
component, as well as my Prismic client, and my index
page component, so you have an idea of the code I'm workin with.
ANSWER
Answered 2021-Jan-08 at 11:39You can add getInitialProps
to your custom _app
page (getServerSideProps
and getStaticProps
are not supported).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install prismic-javascript
Node.js project
Node.js blog
Next.js project
Node.js project
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page