The state tree is the single source of truth for any given store. Once a store has been created, the state tree is strictly readonly. The initial state for a store is defined upon store creation.

Defining State

const STATE = {
    firstName: 'John',
    lastName: 'Smith'

const {
} = createStore('user', STATE);

state.firstName = 'Jane'; // This will throw an error

Usage in Components

    <div class="app">
        <h1>Hello {{ state.firstName }}</h1>

<script lang="ts" setup>
import {
} from './stores/user';

See Also

State API Reference