Router macros for PhoenixDatastar.
Usage
import PhoenixDatastar.Router
scope "/", MyAppWeb do
pipe_through :browser
# Stateless view (use PhoenixDatastar)
datastar "/counter", CounterStar
# Live view (use PhoenixDatastar, :live)
datastar "/multiplayer", MultiplayerStar
# With custom HTML module
datastar "/custom", CustomStar, html_module: MyAppWeb.CustomHTML
enddatastar/3 generates per-view routes:
- GET /counter - renders the initial page
- POST /counter/_event/:event - handles events
- GET /counter/stream - SSE stream endpoint (live views only)
Configuration
Set a default HTML module in your config:
config :phoenix_datastar, :html_module, MyAppWeb.DatastarHTMLOr pass html_module option per-route to override.
Summary
Functions
Defines routes for a PhoenixDatastar view.
Functions
Defines routes for a PhoenixDatastar view.
The macro auto-detects whether the view is stateless (use PhoenixDatastar) or
live (use PhoenixDatastar, :live) and generates appropriate routes.
Options
:html_module- The Phoenix HTML module to use for rendering the mount template. Defaults toApplication.get_env(:phoenix_datastar, :html_module).