README
Datastar SDK examples
These examples port the demonstrations in
datastar-go/cmd/examples
to data-oriented Raku. They use only Datastar::SDK and Raku's socket API.
Run the commands from the repository root so Raku++ can load both the SDK and the private example HTTP adapter:
rakupp -Ilib -Iexamples/lib examples/helloworld/main.raku
rakupp -Ilib -Iexamples/lib examples/hotreload/main.rakuThe examples also run with Rakudo:
raku -Ilib -Iexamples/lib examples/helloworld/main.raku
raku -Ilib -Iexamples/lib examples/hotreload/main.rakuHello World
Open http://127.0.0.1:1337, choose a delay, and press Start. The browser
sends the delay signal to /hello-world; the backend validates it and
streams every prefix of Hello, world! as a complete element with the stable
ID message.
Pass a different port as the first argument:
rakupp -Ilib -Iexamples/lib examples/helloworld/main.raku 8080Hot reload
Open http://127.0.0.1:9001, then edit and save
examples/hotreload/hotreload.html. The backend owns the file-change watch.
The browser holds an SSE request to /hotreload; when the file changes, the
backend streams a reload script and the browser reconnects.
This reproduces the Go example's browser behavior without requiring Reflex or another file-watcher dependency.
Pass a different port and page path as positional arguments:
rakupp -Ilib -Iexamples/lib \
examples/hotreload/main.raku \
9002 examples/hotreload/hotreload.htmlNative binaries
Compile either server through Raku++'s native C++ path:
RAKULIB=lib:examples/lib \
rakupp --exe examples/helloworld/main.raku -o /tmp/datastar-hello
RAKULIB=lib:examples/lib \
rakupp --exe examples/hotreload/main.raku -o /tmp/datastar-hotreloadThe compile step should report Compiled (native). Run the binaries from the
repository root with the same RAKULIB value so their modules remain
available:
RAKULIB=lib:examples/lib /tmp/datastar-hello
RAKULIB=lib:examples/lib /tmp/datastar-hotreloadThe HTTP adapter under examples/lib is intentionally example infrastructure,
not part of the public Datastar::SDK API.