[Link resolver error] Unknown type Declared type: homepage Expected one of:\n



I have setup the routes, and file correctly, I dont understand why I am still getting Link Resolver Error. I have also tried to clean .next cache

Hey @mr_g,

Have you created a page type with the ID of homepage, pushed your changes to your repository, and published at least one document with the homepage type?

Sam

I also have the problem when opening the page. I tried creating a page type with the ID of home and pushed the changes but it still doesn't work


Hi @arianne.dangvankhanh,

Welcome to the community!

Can you make the type home instead of page and let me know if that works? :slight_smile:



You mean like this? It also doesn't work

Sorry, that's my bad, I should have been clearer. I mean line 15 of your prismicio.ts file :slight_smile:


It also doesn't work at that case even I tried to change line 15 and 16 to the type "home"

The type has to match all the way through: in your repository, in your prismicio.ts set up, and in the way you're calling it in your /app/page.tsx file.

You need to have a home page that says 'home' where type is:

Once you've got that, try keeping your line 15 as it is in that screenshot, then to replace your line 32 with this: const page = await client.getSingle("home");.

Let me know how that goes!


i didn't see the page like your screenshot. Is it this one?

And in page.tsx, do I need to change the line 17 too, and when I replace the line like you. It alerts something wrong

The screenshot I sent you is the one in the dashboard of your repository. You're correct for line 17! It all needs to match.

From the documentation:

client.getByUID() is used like this: client.getByUID(documentType, uid);.

Accepts a Custom Type API ID as a string, a UID as a string, and an optional params object. Queries your Prismic repository for the document of the given Custom Type with the given UID. Returns a promise that resolves with the API response.

For the homepage, singe you would only have one, we recommend just using getSingle("type"). It queries a singleton document from the Prismic repository for a specific custom type. type refers to the API ID of the custom type, like in (for example) const document = await client.getSingle("home");.

Try to make a singleton type "home" for your home page in your repository. Push the changes, publish a document of that type, and then you query it as mentioned. It should work from there.

Let me know if I need to clarify anything else :slight_smile:

Really sorry but I did not see where it is. I tried to search all tabs but I did not see :pensive:

That's okay! It would be in your Main Space. You want to click the create new page button there, and make your home page. Have you published a first document yet?

If you're just starting out, feel free to follow the process in the documentation here: Install Prismic with Next.js - Documentation - Prismic. You can also checkout the Prismic youtube channel, where we have a bunch of tutorial to set you up :slight_smile:

1 Like