For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/index.md.
  • English
  • Entry Points

    Capabilities are split by subpath so hosts can load only what they need. The root entry is the main entry; react-wikitext/view is a lightweight entry that does not load the parser.

    Pipeline

    source
      └─ /parse ─▶ WikitextDocument (original parse snapshot)
            └─ /hast prepare ─▶ WikitextRenderDocument (HAST + headings + meta)
                  └─ /view ─▶ React

    Optional pre-stage:

    source ─▶ /expand ─▶ expanded WikitextDocument ─▶ /hast ─▶ /view

    Subpaths

    SubpathContentsLoads parserLoads React
    react-wikitextWikitext, WikitextView, WikitextFragment, context hooks, component types, selected semantic typesYesYes
    react-wikitext/astSemantic model, queries, helpers, pure parser factory, source normalization, serializationNoNo
    react-wikitext/parseDefault parser, parseWikitext, parse options, parse errorsYesNo
    react-wikitext/expandexpandWikitext, expansion types and errorsYesNo
    react-wikitext/hastprepareWikitext, prepareWikitextAsync, resolvers, policy, labels, heading strategies, URL utilities, render snapshot serializationNoNo
    react-wikitext/unifiedwikitextParse, wikitextRehype, wikitextFinalizeNo (parser must be injected)No
    react-wikitext/viewWikitextView, WikitextFragment, context hooks, component typesNoYes
    react-wikitext/configsMEDIAWIKI_CONFIG, ParserConfigNoNo
    react-wikitext/styles.cssPage rendering styles——

    The root entry does not export anything from the parse, expand, hast, or unified subpaths. /ast, /hast, /unified, and /configs do not load the default parser; /parse and /expand do; /view loads only React and an already prepared document. The AST tree and node inspector live in the internal playground and are not public entries.

    Parse and render snapshots

    Parse snapshot WikitextDocument

    interface WikitextDocument {
      readonly source: string;
      readonly ast: WikitextRoot;
      readonly syntax?: WikitextSyntaxRoot;
      readonly meta: WikitextDocumentMeta;
      readonly diagnostics: readonly WikitextDiagnostic[];
    }
    • ast is the original normalized result; preparation never mutates it.
    • syntax exists only with retainSyntax: true and serves the playground and source positions.
    • meta records parser name/version, page name, normalization state, and the original length.

    Render snapshot WikitextRenderDocument

    interface WikitextRenderDocument {
      readonly source: string;
      readonly ast: WikitextRoot; // working tree result
      readonly hast: import("hast").Root; // sanitized final HAST
      readonly headings: readonly WikitextHeadingInfo[];
      readonly meta: WikitextRenderMeta;
      readonly diagnostics: readonly WikitextDiagnostic[];
    }
    • ast is the plug-in-processed working tree with reassigned node ids.
    • hast is sanitized and finalized, including the table of contents, reference section, and category footer.
    • meta records the effective policy, labels, heading strategy, and authorized images.
    • WikitextView accepts only a render snapshot, never source.

    Query transformed nodes with the render snapshot. Do not use ids from the render snapshot to look up the original parse snapshot.

    How to choose

    NeedUse
    Render source directly on the clientRoot Wikitext
    Prepare on the server, render on the client/parse + /hast + /view
    Parse only or inspect the AST/parse + /ast
    Expand templates, then render/expand + /hast + /view
    Integrate with a unified processor/unified (inject parser explicitly)
    Swap site configuration only/configs + /parse

    Types and errors

    • Error classes are exported from their respective entries: /ast and /parse expose WikitextError / WikitextParseError; /expand exposes WikitextExpandError; /hast exposes WikitextPrepareError. The root entry and /view do not export error classes.
    • The WikitextLabels type is available from /ast and /view; DEFAULT_WIKITEXT_LABELS and DEFAULT_PREPARE_POLICY come from /hast.
    • Import the full set of node subtypes from /ast; the root entry exports only selected semantic types used by view props.
    • Error codes, stage, and diagnostic fields are documented in Errors and diagnostics.

    Reference pages

    SubpathPage
    Root, /viewReact components
    /parseParsing
    /astAST
    /hastPreparation
    /expandExpansion
    /unifiedunified
    /configsconfigs

    Next steps