Skip to content

TypeScript with Sprig's Function-Based API ​

Sprig does not implement Vue's Composition API, but its function-based signal API is typed. For example, signal(0) infers a numeric getter/setter pair, and computed(() => count() * 2) infers a numeric getter. The exported Accessor, Setter, and component types are declared in the core entry.

ts
import { computed, signal } from 'sprig-framework';

const [count, setCount] = signal(0);
const doubled = computed(() => count() * 2);
setCount((current) => current + 1);

This is Sprig's API, not a Vue Composition API compatibility layer. .sprig scripts remain JavaScript-only.