Quick Example
useLocalStorage Usage
ตัวอย่าง import และการใช้งานแบบสั้นสำหรับหน้า `use-local-storage`
Code
<script lang="ts">
import { useLocalStorage } from 'svelora';
const theme = useLocalStorage('theme', 'system');
</script>
<button onclick={() => (theme.current = 'dark')}>
{theme.current}
</button>
useLocalStorage
Reactive localStorage-backed value. Reads on mount, writes through on
change, and syncs across tabs via the storage event. SSR-safe; parse/quota errors
are tolerated.
Persisted text
Type below, then reload the page — the value persists. Open this page in a second tab to see live cross-tab sync.
Stored under key svelora-demo-note.
Persisted counter
0