facebook/lexical · error

LinkPlugin: LinkNode not registered on editor

Error message

LinkPlugin: LinkNode not registered on editor

What it means

LinkPlugin registers link behavior that operates on LinkNode, so it verifies the editor has LinkNode registered and throws otherwise. Lexical only recognizes node classes explicitly configured on the editor. The check runs in a useEffect at mount, surfacing the misconfiguration immediately when the plugin renders.

Source

Thrown at packages/lexical-react/src/LexicalLinkPlugin.ts:36

/**
 * Enables {@link LinkNode} support, registering the commands and transforms
 * that toggle and normalize links. Pass `validateUrl` to restrict which URLs
 * may be applied (which also enables automatic link creation when pasting a
 * matching URL) and `attributes` to set defaults such as `target` or `rel`.
 * The editor must have the {@link LinkNode} registered.
 *
 * This is a legacy plugin. When building an editor with the extension API,
 * configure {@link LinkExtension} instead.
 *
 * @returns `null`, this plugin renders no DOM of its own.
 */
export function LinkPlugin({validateUrl, attributes}: Props): null {
  const [editor] = useLexicalComposerContext();

  useEffect(() => {
    if (!editor.hasNodes([LinkNode])) {
      throw new Error('LinkPlugin: LinkNode not registered on editor');
    }
  });
  useEffect(() => {
    return registerLink(editor, namedSignals({attributes, validateUrl}));
  }, [editor, validateUrl, attributes]);

  return null;
}

View on GitHub (pinned to 76a22dcba9)

Solutions

  1. Add LinkNode (and AutoLinkNode if using autolinks) from @lexical/link to the editor's nodes array
  2. Use the link extension with buildEditorFromExtensions to register nodes automatically
  3. Check editor.hasNodes([LinkNode]) before rendering the plugin

Example fix

// before
const initialConfig = {nodes: [ParagraphNode, TextNode, AutoLinkNode]};
<LinkPlugin /> // throws: LinkNode missing

// after
import {LinkNode, AutoLinkNode} from '@lexical/link';
const initialConfig = {nodes: [ParagraphNode, TextNode, LinkNode, AutoLinkNode]};
<LinkPlugin /> // ok
Defensive patterns

Strategy: validation

Validate before calling

import {LinkNode, AutoLinkNode} from '@lexical/link';
if (!editor.hasNodes([LinkNode])) {
  throw new Error('Add LinkNode to your editor nodes config before using LinkPlugin');
}

Type guard

function supportsLinks(editor: LexicalEditor): boolean {
  return editor.hasNodes([LinkNode]);
}

Try / catch

try {
  if (!editor.hasNodes([LinkNode])) throw new Error('LinkNode missing');
  // safe to use LinkPlugin
} catch (e) {
  console.error('LinkPlugin misconfigured:', e);
}

Prevention

When it happens

Trigger: Rendering <LinkPlugin /> in a LexicalComposer whose editor config lacks LinkNode (AutoLinkNode alone is not sufficient).

Common situations: Adding the link plugin from docs to an editor with a hand-built nodes list; registering AutoLinkNode but not LinkNode; migrating to @lexical/link package split and dropping the node import.

Related errors


AI-assisted analysis of facebook/lexical@76a22dcba9 (2026-08-31). Data as JSON: /api/errors/d32a764f9581a316. Report an issue: GitHub.