Getting started
Go from a fresh SvelteKit project to a running Squander game in 60 seconds.
Install the stack
From your SvelteKit project, install Squander alongside the Svelte runtime and SvelteKit:
npm install squander@latest svelte@latest @sveltejs/kit@latest If you already have a SvelteKit project, its Svelte and SvelteKit packages are probably installed. The command above shows the complete stack that the example uses.
Mount the Game component
Put this in a route such as src/routes/+page.svelte. Game creates the browser-side game after mount, owns its renderer
and frame loop, and disposes them when the page unmounts.
<script lang="ts">
import { Game, type GameReadyContext } from "squander/svelte";
import type { SceneFactoryContext } from "squander/core/runtime";
const start_game = async ({ scenes }: GameReadyContext): Promise<void> => {
await scenes.mount(({ renderer }: SceneFactoryContext) => ({
name: "main",
draw: () => {
void renderer.clear({ red: 0.05, green: 0.08, blue: 0.15, alpha: 1 });
},
}));
};
</script>
<Game class="game-canvas" onReady={start_game} />
What you get
- A WebGPU canvas initialized through the SvelteKit client lifecycle.
- A running update and draw loop with a game-owned scene stack.
- Automatic cleanup when the Svelte component unmounts.
- A first scene that clears the canvas so you can see the game is alive.
Browser requirements
WebGPU requires a secure context: use http://localhost or http://127.0.0.1 during development and HTTPS in
production. Keep Game in a Svelte component so WebGPU creation stays browser-only; do not create a game during server-side rendering.
When you need lower-level lifecycle control, continue with the game lifecycle guide. For a larger rendered example, open the playground.