An invalid Prismic repository name was given


I've worked on Prismic and everything worked great on that project, but now I am working on a new one with different account, and I'm having difficulty connecting/fetching data this time.

I followed the Next.js Prismic documentation, but I keep getting this error-"An invalid Prismic repository name was given" I am not sure why.


  "_latest": "0.3.8",
  "apiEndpoint": "",
  "libraries": ["@/slices"],
  "localSliceSimulatorURL": "http://localhost:3000/slice-simulator"


import * as prismic from "@prismicio/client";
import { enableAutoPreviews } from "@prismicio/next";
import sm from "./sm.json";

export const endpoint = sm.apiEndpoint;
export const repositoryName = prismic.getRepositoryName(endpoint);

// Update the Link Resolver to match your project's route structure
export function linkResolver(doc) {
  switch (doc.type) {
    case "homepage":
      return "/";
    case "page":
      return `/${doc.uid}`;
    case "project":
      return `/projects/${doc.uid}`;
      return null;

// This factory function allows smooth preview setup
export function createClient(config = {}) {
  const client = prismic.createClient(endpoint, {

    previewData: config.previewData,
    req: config.req,

  return client;

on the page.js, I included

import { createClient } from "@prismicio/client";

export async function getStaticProps({ previewData }) {
  const client = createClient({ previewData });

  const page = await client.getByUID("page", "home");

  return {
    props: { page }, // Will be passed to the page component as props

Wrapped everything with PrismicProvider, PrismicPreview like the documentation, but I'm getting this error.

Hello @hi16, thanks for reaching out.
Did you use a starter to kickstart this new project? Sometimes you need to ensure Slice Machine is configured with your repository name instead of the one provided by default on the starter's sm.json. Are you able to run Slice Machine?

I didn't use starter just followed the instruction to my existing project, and slice machine works good just this error:(

and apiEndpoint link in my sm.json is correct

"apiEndpoint": "",

Is there any other possible reason that this doesn't work? I'm trying to find an error but everything seems to be same as documentation. I cannot get rid of this error. I've tried creating another repository and configure again but it gives same error with this account

Maybe this is an error on our end. Can you please send us the URL of your repository?

Thank you so much

1 Like

Hey @hi16, One of my colleagues was able to spot something in the code you shared:

You're importing createClient() from @prismicio/client from the page.js file. Instead, it should be imported from prismicio.js. Like this:

import { createClient } from "../prismicio";

The createClient() from prismicio.js already has the Prismic repository’s endpoint configured and is enhanced to support Next.js’s Preview Mode via the previewData option. With that import change, the “Invalid Prismic repository name” error should go away.

Continuing the discussion from An invalid Prismic repository name was given:

I have a similar issue with a Quasar project, but I can't figure out how this solution works:

import * as prismic from "@prismicio/client";
import fetch from 'cross-fetch';
const endpoint = prismic.getEndpoint(process.env.PRISMIC_END_POINT);
const client = prismic.createClient(endpoint, { accessToken: process.env.PRISMIC_ACCESS_TOKEN, fetch });

and then I call my async function, like:

await client.getAllByType("exhibition").then((data) => {
    console.log("data", data); = { };

but, I'm getting the error: An invalid Prismic repository name was given:

The above import modules are from The Prismicio-Client Docs.

What am I missing here? Many thanks.

Hi Chris,

Sorry for the delayed reply.

Can you try console logging endpoint to see if you are getting the correct value?

Also try removing { accessToken: process.env.PRISMIC_ACCESS_TOKEN, fetch } because your repo is not set to private so this is unnecessary.