How to query Custom Types in Next.js

Hey!

New to Prismic, I was fascinated by building pages using slices. However I have still not found a use case for it in my experience.

Instead I am currently trying to use Prismic as a regular CMS using Custom Types. I have created and pushed my custom types and now I want to query them in my Next.js project. I found plenty of documentation and video tutorials on setting up Slices and Pages built using slices but I could not find out how to query only for Custom Types without setting up complete pages built using slices.

This is my primsicio.ts (I have put in the correct repo name)

import * as prismic from "@prismicio/client";

const repoName = "repo-name";
const endpoint = prismic.getEndpoint(repoName);
const client = prismic.createClient(endpoint);

export default client;

And then within a getStaticProps I want to query my Custom Types.

I was wondering how I can do that.

Hello @avaneeshsamsi, the next step to query your Custom Types is to use the query methods from @prismicio/client. You can get documents by type, by UID, or by single types:

1 Like

Thank you so much! Hit some lame syntax errors but it seems to be working now. Noticed this question was pretty clear in the @prismicio/client docs. Sorry for asking here anyway

2 Likes