Frontend Pattern Library — React & TypeScript @granit/*
A catalogue of design patterns used in the Granit frontend SDK, organized by category.
Each pattern documents the general concept, how it is implemented in the @granit/*
packages, and concrete code examples from the SDK.
Creation patterns
Section titled “Creation patterns”| Pattern | Description |
|---|---|
| Factory | Hide instance creation complexity behind simple functions |
| Module Singleton | Cross-package state sharing via ES module cache |
Structural patterns
Section titled “Structural patterns”| Pattern | Description |
|---|---|
| Adapter | Convert 3rd-party APIs into React-compatible interfaces |
Behavioral patterns
Section titled “Behavioral patterns”| Pattern | Description |
|---|---|
| Interceptor | Transparent HTTP request/response pipeline processing |
| Strategy | Pluggable implementations behind a common interface |
| Observer | Event notification without direct coupling |
React patterns
Section titled “React patterns”| Pattern | Description |
|---|---|
| Provider | Context-based dependency injection with typed hooks |
| Hook Composition | Layer framework + application logic via hook wrapping |