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:

  1. Remove toy_page: Create a proper Html structure with Head and Body.
  2. Self-host Assets: Use app.assets() to serve a local copy of datastar.js.
  3. Remove toy_inspector: It's too heavy for real users.
  4. Add RichTracer: Use server-side telemetry instead of client-side inspection.