> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# 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

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

Optional pre-stage:

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

## Subpaths

| Subpath                     | Contents                                                                                                                               | Loads parser                 | Loads React |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------- |
| `react-wikitext`            | `Wikitext`, `WikitextView`, `WikitextFragment`, context hooks, component types, selected semantic types                                | Yes                          | Yes         |
| `react-wikitext/ast`        | Semantic model, queries, helpers, pure parser factory, source normalization, serialization                                             | No                           | No          |
| `react-wikitext/parse`      | Default parser, `parseWikitext`, parse options, parse errors                                                                           | Yes                          | No          |
| `react-wikitext/expand`     | `expandWikitext`, expansion types and errors                                                                                           | Yes                          | No          |
| `react-wikitext/hast`       | `prepareWikitext`, `prepareWikitextAsync`, resolvers, policy, labels, heading strategies, URL utilities, render snapshot serialization | No                           | No          |
| `react-wikitext/unified`    | `wikitextParse`, `wikitextRehype`, `wikitextFinalize`                                                                                  | No (parser must be injected) | No          |
| `react-wikitext/view`       | `WikitextView`, `WikitextFragment`, context hooks, component types                                                                     | No                           | Yes         |
| `react-wikitext/configs`    | `MEDIAWIKI_CONFIG`, `ParserConfig`                                                                                                     | No                           | No          |
| `react-wikitext/styles.css` | Page 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`

```ts
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`

```ts
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

| Need                                        | Use                                   |
| ------------------------------------------- | ------------------------------------- |
| Render source directly on the client        | Root `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](/api/errors.md).

## Reference pages

| Subpath       | Page                              |
| ------------- | --------------------------------- |
| Root, `/view` | [React components](/api/react.md) |
| `/parse`      | [Parsing](/api/parse.md)          |
| `/ast`        | [AST](/api/ast.md)                |
| `/hast`       | [Preparation](/api/prepare.md)    |
| `/expand`     | [Expansion](/api/expand.md)       |
| `/unified`    | [unified](/api/unified.md)        |
| `/configs`    | [configs](/api/configs.md)        |

## Next steps

- [React components](/api/react.md): source component, view, Fragment, and context hooks.
- [Parsing `/parse`](/api/parse.md): parsers, budgets, and custom adapters.
- [Preparation `/hast`](/api/prepare.md): plugins, resolvers, policy, and snapshot restore.
- [Errors and diagnostics](/api/errors.md): codes and handling advice.
- [Status and compatibility](/project/status.md): versions, snapshot versions, and runtime requirements.
