Part V — The Modern Experience Layer · Chapter 31 · Lesson 2 of 2
React hooks, data grids and OpenAPI import
The frontend half of the SDK story — generate it, don't write it.
React hooks from routes
generate_react_hooks(spec, { "output": "src/hooks/" })
Each route with a known request/response shape becomes a hook: useOrders(), useCreateOrder(). The hooks carry loading/error/data states, are typed end to end and accept the same fetch wrapper options as a hand-written client — base URL, headers, error mapping.
Data grid and chart adapters
generate_data_grid_adapter(spec, "src/adapters/grid.ts")
generate_chart_adapter(spec, "src/adapters/charts.ts")
The grid adapter shapes records for TanStack Table / AG Grid-style components (column defs, sort, filter, pagination mapping); the chart adapter maps your analytics routes to chart component props. They are starting points, not frameworks — read the generated code; it is deliberately boring.
Streaming and middleware sources
sse_endpoint_source/websocket_handler_source— live endpoints for dashboards and consoles.jwt_middleware_source/rate_limiter_source/api_versioning_source— middleware skeletons with the sharp edges documented.
Vector, RAG and ONNX export (v1.7.0)
let vec = create_vector(embed(text))
let score = cosine_similarity(vec, query_vec)
let hits = hybrid_search(store, "refund policy", 5)
export_model(model, "model.onnx") # model_to_onnx / tree_to_onnx
VectorStore, chunk_text, bm25_score and hybrid_search are enough to ship a real retrieval feature without a vector database. model_to_onnx exports trained trees and pipelines for inference outside PeaLang.
Notebook to webapp (v1.8.0)
publish_as_webapp(notebook) and generate_notebook_html(notebook) turn an analysis notebook into a shareable page — charts, tables and the narrative included. Useful for the "here is what the data said" deliverable that used to be a PDF nobody read.
Guided practice
- Generate React hooks from your OpenAPI spec and mount one in a scratch app; try passing a wrong argument — the compiler must complain.
- Export a small model with
model_to_onnxand load it in Python's onnxruntime; compare predictions on five inputs. - Turn an analysis you already have into a published notebook page and send the link to one skeptic.