Watch a live product demo 👀 See how Sanity powers richer commerce experiences

Internal Link Error in Next.js Application: Unknown mark type "internalLink"

11 replies
Last updated: Aug 14, 2022
Piggybacking off the above, when adding an internal link with
and build my nextjs application, I get
Unknown mark type "internalLink", specify a component for it in the
However, I am doing
const myPortableTextComponents = {
  marks: {
    internalLink: ({ children, value }) => {
      return (
        <Link href={`/${value.slug.current}`} prefetch={false}>

export const PortableText = (props) => (
  <PortableTextComponent components={myPortableTextComponents} {...props} />
It doesn't break the build but just curious why if I am defining it?
Aug 13, 2022, 5:27 AM
I think you missed one thing: A “link” is expressed as a mark annotation.
Aug 13, 2022, 7:31 AM
Maybe it’s because you are spreading the props?I’d do
<PortableTextComponent value={value} components={myPortableTextComponents} />
to avoid any confusion when I use it.
Aug 13, 2022, 9:43 AM
You might also have a conflict with your
because it’s a named export.Or have you renamed the import?
import { PortableText as SomethingElse } from '@portabletext/react'

Something like that would also avoid confusion:

export const CustomPortableText = ({ value }) => (
  <PortableText value={value} components={myPortableTextComponents} />
Aug 13, 2022, 9:47 AM
I’ll try the value suggestion and yes I renamed the import
Aug 13, 2022, 1:30 PM
So I am doing
export const PortableTextComponent = ({ value }) => (
  <PortableText components={myPortableTextComponents} value={value} />
but I still get

Unknown mark type "internalLink", specify a component for it in the `components.marks` option
Aug 13, 2022, 2:22 PM
Even adding
does nothing...
Aug 13, 2022, 3:38 PM
Can you share your schema?
Aug 13, 2022, 7:05 PM
import { PlugIcon } from "@sanity/icons";export default {
title: "Block Content",
name: "blockContent",
type: "array",
of: [
title: "Block",
type: "block",
// Styles let you set what your user can mark up blocks with. These
// correspond with HTML tags, but you can set any title or value
// you want and decide how you want to deal with it where you want to
// use your content.
styles: [
{ title: "Normal", value: "normal" },
{ title: "H1", value: "h1" },
{ title: "H2", value: "h2" },
{ title: "H3", value: "h3" },
{ title: "H4", value: "h4" },
{ title: "Quote", value: "blockquote" },
lists: [{ title: "Bullet", value: "bullet" }],
// Marks let you mark up inline text in the block editor.
marks: {
// Decorators usually describe a single property – e.g. a typographic
// preference or highlighting by editors.
decorators: [
{ title: "Strong", value: "strong" },
{ title: "Emphasis", value: "em" },
// Annotations can be any object structure – e.g. a link or a footnote.
annotations: [
title: "URL",
name: "link",
type: "object",
fields: [
title: "URL",
name: "href",
type: "url",
validation: (Rule) =>
scheme: ["http", "https", "mailto", "tel"],
name: "internalLink",
title: "Internal Link",
type: "object",
icon: PlugIcon,
fields: [
title: "Reference",
name: "reference",
type: "reference",
to: [{ type: "post" }],
// You can add additional types here. Note that you can't use
// primitive types such as 'string' and 'number' in the same array
// as a block type.
type: "image",
options: { hotspot: true, metaData: ["blurhash", "lqip"] },
type: "player",
type: "twitter",
Aug 13, 2022, 7:32 PM
Well that doesn't format nicely on mobile 🥲
Aug 13, 2022, 7:32 PM
Nothing wrong here, do you get any result from your blockContent when you fetch your data?
Aug 14, 2022, 7:56 AM
Yup everything works as expected
Aug 14, 2022, 11:01 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing