1

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 ?

me-me
  • 5,139
  • 13
  • 50
  • 91

1 Answers1

1

me, 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.

Alex Trost
  • 56
  • 2
  • Thank you for clearing all that up. Will anyone using prismic-javascript need change over to @prismicio/client ? Or does prismic-javascript have everything you need to connect to V2 api for now. Obviously a new user of Prismic should use @prismicio/client – me-me Mar 16 '21 at 15:04
  • 1
    This still hasn't been cleaned up as far as I'm concerned. The GitHub page still makes no mention of the differences between these libraries let alone the old docs for the `prismic-javascript` api. – connected_user May 03 '21 at 08:46