
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
next-slicezone
Advanced tools
A component that fetches Prismic files, returns slices found and matches them with front-end components.
RFC: https://github.com/prismicio/slice-machine/issues/7
Next SliceZone exports 2 functions that are designed to help you quickly get all static paths of a NextJS given route, fetch associated documents on Prismic, and return slices found there.
useGetStaticProps can be used in every page using the SliceZone.
It's responsible for:
getStaticPropsQuery a singleton page of type "homepage"
import { Client } from "../prismic";
import { useGetStaticProps } from "next-slicezone/hooks";
import resolver from "../sm-resolver";
const Page = ({ uid, slices }) => (
<SliceZone resolver={resolver} slices={slices} />
);
export const getStaticProps = useGetStaticProps({
client: Client(),
type: "homepage", // query document of type "page"
queryType: "single", // homepage is a singleton document
});
export default Page;
useGetStaticProps takes a params object as argument.
| Param | Type | Required | Default value | Description | Example value |
|---|---|---|---|---|---|
| apiParams | object | false | null | Object passed to client apiOptions. | { lang: 'fr-fr' } |
| client | function | true | null | Pass a Prismic client here | Prismic.client(apiEndpoint) |
| slicesKey | string | false | body / slices | Key of slices array in API response (doc.data[slicesKey]) | 'MySliceZone' |
| type | string | false | page | Custom type to be queried | 'another_cts' |
| queryType | string | false | repeat | One of 'repeat' or 'single', to switch between getByUID and getSingle calls | 'single' |
| getStaticPropsParams | object | false | null | Object passed to return object of getStatcProps | { revalidate: true } |
Your API calls might depend on other factors in your app, for example the language the user talks. Pass an apiParams object or function to transform your call to the Prismic API.
const PageInFrench = ({ uid, slices }) => (
<SliceZone resolver={resolver} slices={slices} />
);
export const getStaticProps = useGetStaticProps({
client: Client(),
type: "homepage", // query document of type "page"
queryType: "single", // homepage is a singleton document
apiParams: {
lang: "fr-fr",
},
});
export default PageInFrench;
š apiParams can also be a function! See example below
useGetStaticPaths should be used in each dynamic page that relies on the SliceZone.
It's responsible for:
/pages/[lang]/[uid])Query a repeatable type "page" in a language based on URL parameter.
import { useGetStaticProps, useGetStaticPaths } from "next-slicezone/hooks";
const Page = ({ uid, slices, data }) => (
<div>
<h1>{data.keyTextTitle}</h1>
<SliceZone resolver={resolver} slices={slices} />
</div>
);
export const getStaticProps = useGetStaticProps({
type: "page",
queryType: "repeat",
apiParams({ params }) {
// params are passed by getStaticPaths
return {
lang: params.lang,
uid: params.uid,
};
},
});
// fetch all docs of type `MyPage` and pass params accordingly
export const getStaticPaths = useGetStaticPaths({
client: Client(),
type: "page",
formatPath: (prismicDocument) => {
return {
params: {
uid: prismicDocument.uid,
lang: prismicDocument.lang,
},
};
},
});
export default Page;
useGetStaticPaths takes a params object as argument.
Refer to Next docs to understand what's expected from formatPath.
| Param | Type | Required | Default Value | Description | Example |
|---|---|---|---|---|---|
| type | - | - | - | Same as useGetStaticProps | - |
| apiParams | - | - | - | Same as useGetStaticProps | - |
| client | - | - | - | Same as useGetStaticProps | - |
| formatPath | function | true | (doc) => null | Function to format Next path argument. Pass null to skip. | ({uid}) =>({ params:{ uid }}) |
Once slices have been fetched server-side, we need to get all slices found and match them with your components.
To display the right content, the SliceZone takes as parameters
props passed at build time by useGetStaticProps. Notably:
slices, the array data components fetched from Prismicresolver, a function that resolves calls to components from the SliceZonesliceProps, an object or function that passes props to matched slicesconst Page = ({ data, slices }) => (
<SliceZone
slices={slices}
resolver={resolver}
sliceProps={({ slice, sliceName, i }) => ({
theme: i % 1 ? 'light' : 'dark',
alignLeft: data.keyTextTitle?.length > 35
})}
)
The resolver function can be generated for you and should be everytime you make a change to your slices structure (rename, add, delete a slice, add a library...). To do this, create a pages/_document file and add the createResolver method to its getInitialProps method:
import Document, { Html, Head, Main, NextScript } from "next/document";
import { createResolver } from "next-slicezone/resolver";
export default class extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx);
/* In development, generate an sm-resolver.js file
that will map slices to components */
if (process.env.NODE_ENV === "development") {
await createResolver();
}
return { ...initialProps };
}
render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
FAQs
A component that maps other components to Prismic slices
The npm package next-slicezone receives a total of 882 weekly downloads. As such, next-slicezone popularity was classified as not popular.
We found that next-slicezone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 4 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.