Guide › Interactivity
State
state() makes a value reactive and derived() computes from it. You read and write them as plain variables; the compiler rewrites count++ into a signal update.
<script>
let count = state(0)
const double = derived(() => count * 2)
</script>
<button (click)="count++">{{ count }} × 2 = {{ double }}</button>Starting from the server's values
An island's state is rendered on the server first. Its values travel with the HTML, so the browser picks up exactly where the server left off: an initial value like Date.now() isn't computed a second time. Values can be plain JSON, Date, Map, Set, BigInt and undefined; functions and class instances can't be sent.