npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prismic-react-tools

v1.0.4

Published

>

Readme

prismic-react-tools

NPM JavaScript Style Guide

Install

yarn add prismic-react-tools

Usage

Tools that you can use from this set:

  1. Components:
  • PlainText
  • RichText
  • Slice
  • Slices
  1. HOC:
  • withPrismicPreview

Just pass your components and a serializer (optional) to the provider, then you may use the components refered above:

import React, { Component } from 'react'
import { PrismicReactToolsProvider } from 'prismic-react-tools'

// your components to be rendered as slices
import * as components from './components'

// your serializer for prismic data
import { serializer } from './lib'

class Layout extends Component {
  render () {
    return (
      <PrismicReactToolsProvider
        components={components}
        serializer={serializer}
      >
       {/* ... */}
      </PrismicReactToolsProvider>
    )
  }
}

Components

  1. PlainText
//...
// use it with strings
<PlainText
  content="Your name is {{ name }}, and you're {% adjective %}"
  variables={{ adjective: 'cool', name: 'John Ganzas' }}
/>

// use it with single rich text from prismic (asText)
// be aware that you can pass variables here too
<PlainText content={content} />

//...
  1. RichText
//...
// use it with strings
<RichText
  content={content}
  variables={{ myVar: 'Some variable' }}
/>

//...
  1. Slice
//...
// just create your slice in prismic with the
// match name of you component
// example: in Prismic, call your slice `Item List` (Prismic will turn in `item_list`)
// and you just need to be sure you have the component `ItemList`
<Slice {...sliceObjectFromPrismic} />

// then in your component just access to all the data in the props ;)
//...
  1. Slices
//...
// just pass the array with slices and
// this will just map that array and render
// slice by slice
<Slices slices={slicesFromPrismic} />
//...

HOC

  1. withPrismicPreview

Simple simple, this will just create a preview page for you with the same strategy that is used in gatsby-source-prismic-with-magic

import * as pageComponents from '../layouts';
import { withPrismicPreview } from 'prismic-react-tools';
import prismicOptions from '../../prismic-config';

export default withPrismicPreview({ pageComponents, ...prismicOptions });

important note here is to setup the options exactly as in gatsby-source-prismic-with-magic, that way, will be ensuring the preview will be fed by the same data as the static pages

options:

module.exports = {
  accessToken,                    // Prismic access token
  langs,                          // language object ex: { 'en-us': { default: true, path: 'en }, 'pt-pt': { path: 'pt' } }
  layoutsKey = 'page_-_',         // layouts key that match your pages in Prismic
  layoutNameExceptions = {},      // exceptions (view more about this in `gatsby-source-prismic-with-magic`)
  layoutsPath = 'src/layouts',    // layouts path for your page components (used by `gatsby-source-prismic-with-magic`)
  onCreatePage,                   // function that runs on create each page (view `gatsby-source-prismic-with-magic` docs)
  onCreatePages,                  // function that runs on create all pages (view `gatsby-source-prismic-with-magic` docs)
  repositoryName                  // Prismic repository name
}

Nice to know

This set of tools can be really usefull with my Gatsby Prismic fetch plugin

License

MIT © psoaresbj