Roc Solid
Markup in Roc · pages on a native server · components in WebAssembly

Examples · examples/hello

hello

The two files Getting started shows: a page with a button that counts its clicks, and an endpoint. Its main.roc is the one rocx dev writes for an app without one.

SourceREADMEAll the examples

What it shows#

Its page#

All of it: a signal, a button that sets it, and text that reads it. The server renders it; the browser makes the button count.

examples/hello/routes/+page.rocx
import pf.Html
import pf.Solid exposing [create_signal!]

## The page at /: rendered by the server, then live in the browser.
view! = |_| {
	(count!, set_count!) = create_signal!(0.I64)
	<main>
		<h1>Hello, Roc Solid</h1>
		<button on:click={|| set_count!(count!() + 1)}>
			Clicked {count!().to_str()} times
		</button>
	</main>
}

What it's made of#

Its browser half
205.0 KB
wasm, brotli; 260.9 KB gzip
Pages and endpoints
1 + 1
route files' pages, and handlers
Lines of Roc
25
its own .roc and .rocx, blank lines left out
Tests
0
0 expects, 0 node tests
Weighs
205.0 KB of wasm, brotli (260.9 KB gzip, 658.9 KB raw)
Made of
1 page · 1 endpoint · 25 lines of Roc · 0 expects · 0 node tests
Uses
the platform alone

Measured on 2026-11-29 at commit 74eec5b. The wasm is the app's browser half, built with --opt=size; every page also loads start.js, the page's JavaScript, 22.8 KB brotli. All the examples says how they're measured.

Run it#

With the toolchain set up (just setup), start it from its own directory: it builds, serves at http://127.0.0.1:8080 and builds again when you save. Its README says what to look at.

cd examples/hello && ../../bin/rocx dev

To build it, check it and run its tests, from the repository's root:

just examples hello
just examples-release hello   # as deployed: rocx build, then the tests against a server built --opt=speed