Joint session with Vercel: How to build intelligent storefronts (May 15th)

Unknown mark type "internalLink" error despite defining component in marks

11 repliesLast updated: Dec 1, 2025

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

export const PortableText = (props) => (
  <PortableTextComponent components={myPortableTextComponents} {...props} />
)
It doesn't break the build but just curious why if I am defining it?
AI Update

The warning you're seeing should not appear if your component is correctly defined. This warning indicates that @portabletext/react is encountering an internalLink mark type in your content but isn't finding the corresponding component definition—even though you think you've defined it.

Here are the most likely causes and solutions:

1. Component Definition Isn't Being Applied

The most common issue is that your myPortableTextComponents object isn't actually being passed to the PortableText component properly. Double-check that:

2. Schema Mismatch

The mark type name in your Sanity schema must exactly match the key in your components definition. According to the @portabletext/react documentation, verify in your Sanity schema that you've defined the annotation as:

{
  type: 'object',
  name: 'internalLink',  // Must match exactly
  // ... rest of schema
}

Even a small typo or casing difference (InternalLink vs internalLink) will cause this warning.

Your code has a Next.js issue that could cause problems. In Next.js 13+, you should not nest an <a> tag inside <Link>. Update your component to:

const myPortableTextComponents = {
  marks: {
    internalLink: ({ children, value }) => {
      return (
        <Link href={`/${value?.slug?.current || ''}`} prefetch={false}>
          {children}
        </Link>
      )
    },
  },
}

Note: I also added optional chaining (value?.slug?.current) to prevent errors if the data structure isn't what you expect.

4. Controlling Warning Behavior

You can control how the library handles missing components using the onMissingComponent prop:

<PortableTextComponent 
  components={myPortableTextComponents} 
  onMissingComponent={(message, options) => {
    console.warn(message, options)
  }}
  {...props} 
/>

However, this is just for debugging—the warning shouldn't appear in the first place if everything is configured correctly.

Verification Steps

The key point: this warning means the library genuinely can't find your component definition. It's not "informational" or "expected"—it indicates a configuration mismatch that needs to be resolved. Make sure your schema annotation name exactly matches your component key, and verify that your custom PortableText wrapper is actually being used throughout your application.

Show original thread
11 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions