# yewstack/yew architecture

> Architecture diagram of the GitHub repository yewstack/yew, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yewstack/yew
- Repository: https://github.com/yewstack/yew

## Overview

Yew is a Rust/WebAssembly frontend framework. Developers declare interactive views with the HTML and component macros; the framework represents and renders those views into the browser DOM, where component state, hooks, and context support interaction. Routing and agent packages add navigation and background computation, while server-side rendering is a documented capability. The graph includes these product branches; unsampled runtime wiring is left unasserted or marked unverified.

Main entry points: [`packages/yew-agent/src/scope_ext.rs`](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/scope_ext.rs) (Agent scope APIs), [`packages/yew-macro/src/html_tree/mod.rs`](https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/html_tree/mod.rs) (HTML macro), [`packages/yew-macro/src/html_tree`](https://github.com/yewstack/yew/tree/master/packages/yew-macro/src/html_tree) (HTML parsers), [`packages/yew/src/dom_bundle`](https://github.com/yewstack/yew/tree/master/packages/yew/src/dom_bundle) (DOM updates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["View authoring"]
  node_html_macro["HTML macro<br/>[mod.rs]"]
  node_html_parts["HTML parsers"]
  node_props_macro["Props parsing<br/>[prop.rs]"]
  node_stringify["Token formatting<br/>[stringify.rs]"]
end

subgraph group_runtime["UI runtime"]
  node_components["Component runtime<br/>[mod.rs]"]
  node_functional["Function components<br/>[mod.rs]"]
  node_hooks["Context hook<br/>[use_context.rs]"]
  node_context["Context provider<br/>[context.rs]"]
  node_vdom["Virtual DOM<br/>[mod.rs]"]
  node_dom_bundle["DOM updates"]
  node_fragment["Hydration fragments<br/>[fragment.rs]"]
  node_callbacks["Callbacks<br/>[callback.rs]"]
end

subgraph group_navigation["Routing"]
  node_router["Router component<br/>[router.rs]"]
  node_navigator["Navigator<br/>[navigator.rs]"]
  node_route_derive["Route derive<br/>[routable_derive.rs]"]
  node_route_links["Route links<br/>[link.rs]"]
end

subgraph group_agents["Background agents"]
  node_worker["Worker agents<br/>[provider.rs]"]
  node_worker_hooks["Worker hooks<br/>[hooks.rs]"]
  node_reactor["Reactor agents<br/>[provider.rs]"]
  node_reactor_hooks["Reactor hooks<br/>[hooks.rs]"]
  node_oneshot["Oneshot agents<br/>[provider.rs]"]
  node_agent_scope["Agent scope APIs<br/>[scope_ext.rs]"]
end

subgraph group_rendering["Server rendering"]
  node_server_renderer["SSR renderer<br/>[server_renderer.rs]"]
end

node_developer(("App developer"))
node_browser["Browser DOM"]

node_developer -->|"declares views"| node_html_macro
node_html_macro -->|"parses syntax"| node_html_parts
node_html_parts -->|"uses props parsing"| node_props_macro
node_html_parts -->|"uses formatting"| node_stringify
node_html_macro -.->|"produces views"| node_vdom
node_vdom -.->|"drives DOM updates"| node_dom_bundle
node_dom_bundle -.->|"mutates DOM"| node_browser
node_dom_bundle -->|"uses hydration fragments"| node_fragment
node_functional -.->|"provides hook API"| node_hooks
node_hooks -->|"subscribes to context"| node_context
node_context -->|"notifies consumers"| node_callbacks
node_router -->|"creates navigator"| node_navigator
node_route_derive -.->|"supplies route support"| node_router
node_route_links -.->|"uses routing context"| node_router
node_agent_scope -->|"exposes worker scope"| node_worker
node_agent_scope -->|"exposes reactor scope"| node_reactor
node_agent_scope -->|"exposes oneshot scope"| node_oneshot
node_worker_hooks -.->|"bridges worker agents"| node_worker
node_reactor_hooks -.->|"bridges reactor agents"| node_reactor
node_developer -->|"renders on server"| node_server_renderer

click node_html_macro "https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/html_tree/mod.rs"
click node_html_parts "https://github.com/yewstack/yew/tree/master/packages/yew-macro/src/html_tree"
click node_props_macro "https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/props/prop.rs"
click node_stringify "https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/stringify.rs"
click node_components "https://github.com/yewstack/yew/blob/master/packages/yew/src/html/component/mod.rs"
click node_functional "https://github.com/yewstack/yew/blob/master/packages/yew/src/functional/mod.rs"
click node_hooks "https://github.com/yewstack/yew/blob/master/packages/yew/src/functional/hooks/use_context.rs"
click node_context "https://github.com/yewstack/yew/blob/master/packages/yew/src/context.rs"
click node_vdom "https://github.com/yewstack/yew/blob/master/packages/yew/src/virtual_dom/mod.rs"
click node_dom_bundle "https://github.com/yewstack/yew/tree/master/packages/yew/src/dom_bundle"
click node_fragment "https://github.com/yewstack/yew/blob/master/packages/yew/src/dom_bundle/fragment.rs"
click node_callbacks "https://github.com/yewstack/yew/blob/master/packages/yew/src/callback.rs"
click node_router "https://github.com/yewstack/yew/blob/master/packages/yew-router/src/router.rs"
click node_navigator "https://github.com/yewstack/yew/blob/master/packages/yew-router/src/navigator.rs"
click node_route_derive "https://github.com/yewstack/yew/blob/master/packages/yew-router-macro/src/routable_derive.rs"
click node_route_links "https://github.com/yewstack/yew/blob/master/packages/yew-router/src/components/link.rs"
click node_worker "https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/worker/provider.rs"
click node_worker_hooks "https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/worker/hooks.rs"
click node_reactor "https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/reactor/provider.rs"
click node_reactor_hooks "https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/reactor/hooks.rs"
click node_oneshot "https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/oneshot/provider.rs"
click node_agent_scope "https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/scope_ext.rs"
click node_server_renderer "https://github.com/yewstack/yew/blob/master/packages/yew/src/server_renderer.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_html_macro,node_html_parts,node_props_macro,node_stringify,node_browser toneBlue
class node_components,node_functional,node_hooks,node_context,node_vdom,node_dom_bundle,node_fragment,node_callbacks toneAmber
class node_router,node_navigator,node_route_derive,node_route_links toneMint
class node_worker,node_worker_hooks,node_reactor,node_reactor_hooks,node_oneshot,node_agent_scope toneRose
class node_server_renderer,node_developer toneIndigo
```

## Components

### View authoring

- [HTML macro](https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/html_tree/mod.rs): `packages/yew-macro/src/html_tree/mod.rs`
- [HTML parsers](https://github.com/yewstack/yew/tree/master/packages/yew-macro/src/html_tree): `packages/yew-macro/src/html_tree`
- [Props parsing](https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/props/prop.rs): `packages/yew-macro/src/props/prop.rs`
- [Token formatting](https://github.com/yewstack/yew/blob/master/packages/yew-macro/src/stringify.rs): `packages/yew-macro/src/stringify.rs`

### UI runtime

- [Component runtime](https://github.com/yewstack/yew/blob/master/packages/yew/src/html/component/mod.rs): `packages/yew/src/html/component/mod.rs`
- [Function components](https://github.com/yewstack/yew/blob/master/packages/yew/src/functional/mod.rs): `packages/yew/src/functional/mod.rs`
- [Context hook](https://github.com/yewstack/yew/blob/master/packages/yew/src/functional/hooks/use_context.rs): `packages/yew/src/functional/hooks/use_context.rs`
- [Context provider](https://github.com/yewstack/yew/blob/master/packages/yew/src/context.rs): `packages/yew/src/context.rs`
- [Virtual DOM](https://github.com/yewstack/yew/blob/master/packages/yew/src/virtual_dom/mod.rs): `packages/yew/src/virtual_dom/mod.rs`
- [DOM updates](https://github.com/yewstack/yew/tree/master/packages/yew/src/dom_bundle): `packages/yew/src/dom_bundle`
- [Hydration fragments](https://github.com/yewstack/yew/blob/master/packages/yew/src/dom_bundle/fragment.rs): `packages/yew/src/dom_bundle/fragment.rs`
- [Callbacks](https://github.com/yewstack/yew/blob/master/packages/yew/src/callback.rs): `packages/yew/src/callback.rs`

### Routing

- [Router component](https://github.com/yewstack/yew/blob/master/packages/yew-router/src/router.rs): `packages/yew-router/src/router.rs`
- [Navigator](https://github.com/yewstack/yew/blob/master/packages/yew-router/src/navigator.rs): `packages/yew-router/src/navigator.rs`
- [Route derive](https://github.com/yewstack/yew/blob/master/packages/yew-router-macro/src/routable_derive.rs): `packages/yew-router-macro/src/routable_derive.rs`
- [Route links](https://github.com/yewstack/yew/blob/master/packages/yew-router/src/components/link.rs): `packages/yew-router/src/components/link.rs`

### Background agents

- [Worker agents](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/worker/provider.rs): `packages/yew-agent/src/worker/provider.rs`
- [Worker hooks](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/worker/hooks.rs): `packages/yew-agent/src/worker/hooks.rs`
- [Reactor agents](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/reactor/provider.rs): `packages/yew-agent/src/reactor/provider.rs`
- [Reactor hooks](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/reactor/hooks.rs): `packages/yew-agent/src/reactor/hooks.rs`
- [Oneshot agents](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/oneshot/provider.rs): `packages/yew-agent/src/oneshot/provider.rs`
- [Agent scope APIs](https://github.com/yewstack/yew/blob/master/packages/yew-agent/src/scope_ext.rs): `packages/yew-agent/src/scope_ext.rs`

### Server rendering

- [SSR renderer](https://github.com/yewstack/yew/blob/master/packages/yew/src/server_renderer.rs): `packages/yew/src/server_renderer.rs`

### Other components

- **App developer**
- **Browser DOM**

## Connections

- App developer → HTML macro: declares views (evidence: `README.md`)
- HTML macro → HTML parsers: parses syntax (evidence: `packages/yew-macro/src/html_tree/mod.rs`)
- HTML parsers → Props parsing: uses props parsing (evidence: `packages/yew-macro/src/html_tree/html_element.rs`)
- HTML parsers → Token formatting: uses formatting (evidence: `packages/yew-macro/src/html_tree/html_dashed_name.rs`)
- HTML macro → Virtual DOM: produces views
- Virtual DOM → DOM updates: drives DOM updates (evidence: `packages/yew/src/dom_bundle/fragment.rs`)
- DOM updates → Browser DOM: mutates DOM
- DOM updates → Hydration fragments: uses hydration fragments (evidence: `packages/yew/src/dom_bundle/fragment.rs`)
- Function components → Context hook: provides hook API (evidence: `packages/yew/src/functional/hooks/use_context.rs`)
- Context hook → Context provider: subscribes to context (evidence: `packages/yew/src/functional/hooks/use_context.rs`)
- Context provider → Callbacks: notifies consumers (evidence: `packages/yew/src/context.rs`)
- Router component → Navigator: creates navigator (evidence: `packages/yew-router/src/router.rs`)
- Route derive → Router component: supplies route support
- Route links → Router component: uses routing context
- Agent scope APIs → Worker agents: exposes worker scope (evidence: `packages/yew-agent/src/scope_ext.rs`)
- Agent scope APIs → Reactor agents: exposes reactor scope (evidence: `packages/yew-agent/src/scope_ext.rs`)
- Agent scope APIs → Oneshot agents: exposes oneshot scope (evidence: `packages/yew-agent/src/scope_ext.rs`)
- Worker hooks → Worker agents: bridges worker agents
- Reactor hooks → Reactor agents: bridges reactor agents
- App developer → SSR renderer: renders on server
