Toys Reference ¶
"Toys" are development utilities that eliminate boilerplate when prototyping Datastar apps.
Warning: Never use Toys in production. They load Datastar from a CDN and are not optimized.
toy_page ¶
Wraps your component in a full HTML document with Datastar and a debug inspector pre-loaded.
from stario.toys import toy_page
async def playground(c: Context, w: Writer):
w.html(
toy_page(
Div(H1("Quick Prototype"), ...),
page_title="Stario Lab"
)
)
toy_inspector ¶
A floating debug panel that displays the current value of all Datastar signals.
from stario.toys import toy_inspector
async def my_handler(c: Context, w: Writer):
w.html(
Div(
H1("My App"),
toy_inspector() # Signals appear in top-right
)
)
Transitioning to Production ¶
When you're ready to move beyond the prototype:
- Remove
toy_page: Create a properHtmlstructure withHeadandBody. - Self-host Assets: Use
app.assets()to serve a local copy ofdatastar.js. - Remove
toy_inspector: It's too heavy for real users. - Add
RichTracer: Use server-side telemetry instead of client-side inspection.
