Catalog npm
PACKAGE EXPLORERView in registry

5velte-ph4ser

npm

Svelte 5 components and hooks for building Phaser 4 games

gamephasersveltewebgl
Versions collected3
Direct dependencies2From release 1.0.2
Last observed20 Oct, 20:40 UTC

README

Current package documentation

svelte-phaser

Svelte 5 components and hooks for building Phaser 4 games.

A modern rewrite of the original svelte-phaser (Svelte 3 / Phaser 3) using runes, snippets and callback props — targeting Svelte ^5 and Phaser ^4.

The two layers

LayerWhatWhere it works
Core (svelte-phaser/core, JSR: @easierbycode/svelte-phaser)Pure TypeScript: context getters, event hooks, prop appliers, and compiler-free hooks (useSprite, useArcadePhysics, createGame, …). Reactivity flows out through svelte/store and in through per-step prop syncing — no runes, no .svelte files.Anywhere — including installed from JSR, which only accepts JS/TS modules.
Components (svelte-phaser).svelte components (<Game>, <Scene>, <Sprite>, …) built on the core, with fine-grained $effect prop bindings.npm / workspace installs, where your bundler's Svelte plugin compiles library source.

Why the split? JSR's module graph only accepts JavaScript/TypeScript — .svelte files (and rune code, which needs the Svelte compiler) cannot be published there (jsr-io/jsr#861). The core layer is designed to be fully usable without the compiler, so the JSR package is a real, working game-binding API — not a stub.

Install

From JSR (core API):

npx jsr add @easierbycode/svelte-phaser

From a workspace / local checkout (components + core) — note the unscoped svelte-phaser name on the npm registry belongs to the original Svelte 3 project, so install this package by path:

npm install phaser svelte
npm i 5velte-ph4ser

(see examples/dino, which consumes it via file:../..)

Components example

<script lang="ts">
  import Phaser from 'phaser'
  import { Game, Scene, Sprite, Text } from 'svelte-phaser'

  function preload(scene: Phaser.Scene) {
    scene.load.image('player', 'assets/player.png')
  }
</script>

<Game width={800} height={600} physics={{ default: 'arcade' }}>
  <Scene key="main" {preload}>
    {#snippet loading(progress)}
      <Text x={400} y={300} text={`Loading ${Math.round(progress * 100)}%`} />
    {/snippet}

    <Sprite texture="player" x={400} y={300} />
  </Scene>
</Game>

Components

  • <Game> — creates the Phaser.Game. Accepts game config as props, a booting snippet, and bind:instance.
  • <Scene key> — creates and registers a Phaser.Scene. Accepts preload / create / init callbacks, a loading snippet (receives progress 0–1), and bind:instance.
  • <Sprite>, <Text>, <TileSprite>, <Rectangle>, <Container> — game objects. Props apply reactively; omitted props keep Phaser defaults. Phaser events surface as callback props (onpointerdown, onanimationcomplete, …).
  • <ArcadePhysics> — enables an arcade body on the parent game object (velocityX, bounce, collideWorldBounds, circle, …).
  • <ArcadeCollider with={...} overlapOnly oncollide={...}> — collides the parent game object with other objects, or with names (string targets are matched against gameObject.name, including objects spawned later).
  • <Spawner> — provides getSpawner() context so gameplay code can imperatively spawn(Component, props) (bullets, pickups, …). Spawned components receive an onDestroy prop to remove themselves.

Context + events (both layers)

import {
  getGame, getScene, getSpawner, getGameObject, getContainer,
  onGameEvent, onSceneEvent, onInputEvent, onArcadePhysicsEvent,
} from 'svelte-phaser'

const scene = getScene()
onGameEvent('step', () => { /* runs every game step */ })
onInputEvent('pointerdown', () => { /* ... */ })

Hooks example (core / JSR API)

The hooks create the same objects without any library .svelte files. Pass a props getter — it is re-read every game step and only changed values are re-applied to Phaser:

<script lang="ts">
  import { createGame, createScene, useSprite, useArcadePhysics }
    from '@easierbycode/svelte-phaser'

  // inside your own components:
  const sprite = useSprite(() => ({ texture: 'player', x, y }))
  useArcadePhysics(() => ({ velocityX, collideWorldBounds: true }), sprite)
</script>
  • createGame(config) → { game, booted } (booted is a store)
  • createScene({ key, preload, create }) → { scene, loading, progress } (stores)
  • createSpawner() → { spawn } — mounts components imperatively with the current context (uses Svelte's public mount/unmount)
  • useSprite / useText / useTileSprite / useRectangle / useContainer(getProps)
  • useArcadePhysics(getProps, gameObject?), useArcadeCollider(props, gameObject?)
  • applyGameObjectProps(...) etc. — the underlying idempotent prop appliers

All hooks must be called during component initialisation (they use Svelte context and lifecycle under the hood).

Examples

  • examples/dino — a complete dino-runner game (a port of dino): runes-driven game state rendered declaratively with <Container>/<Rectangle>/<Text>, keyed {#each} obstacle spawning, onGameEvent/onInputEvent, and reactive theme/color customization. cd examples/dino && npm install && npm run dev. The deployable full-stack version (Deno Deploy + PostgreSQL leaderboard) lives at dino-sp.
  • mario-sp

Publishing

  • JSR: npx jsr publish from this directory publishes the core layer as @easierbycode/svelte-phaser (see jsr.json). Run npm install here first so the bare svelte/phaser specifiers type-check, then validate with npx jsr publish --dry-run.
  • npm: the package ships uncompiled .svelte/TS source, which @sveltejs/vite-plugin-svelte compiles in the consuming app (the svelte export condition points at the source). The unscoped svelte-phaser npm name is taken by the original project, so publishing to npm requires a scoped rename (e.g. @easierbycode/svelte-phaser) in package.json.

Requirements

  • svelte ^5.0
  • phaser ^4.0
  • For the component layer: a bundler with the Svelte plugin (e.g. Vite + @sveltejs/vite-plugin-svelte)

Downloads & popularity

0downloads
1-day window · source-reported counts19 Oct 2026
15577.50
2026-07-22: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-22–2026-07-222026-07-23: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-23–2026-07-232026-07-24: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-24–2026-07-242026-07-25: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-25–2026-07-252026-07-26: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-26–2026-07-262026-07-27: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-27–2026-07-272026-07-28: 2 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-28–2026-07-282026-07-29: 1 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-29–2026-07-292026-07-30: 3 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-30–2026-07-302026-07-31: 1 · observed 2026-10-20T21:34:23.0536876Z · period 2026-07-31–2026-07-312026-08-01: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-01–2026-08-012026-08-02: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-02–2026-08-022026-08-03: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-03–2026-08-032026-08-04: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-04–2026-08-042026-08-05: 2 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-05–2026-08-052026-08-06: 3 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-06–2026-08-062026-08-07: 3 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-07–2026-08-072026-08-08: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-08–2026-08-082026-08-09: 1 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-09–2026-08-092026-08-10: 8 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-10–2026-08-102026-08-11: 1 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-11–2026-08-112026-08-12: 3 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-12–2026-08-122026-08-13: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-13–2026-08-132026-08-14: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-14–2026-08-142026-08-15: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-15–2026-08-152026-08-16: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-16–2026-08-162026-08-17: 3 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-17–2026-08-172026-08-18: 1 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-18–2026-08-182026-08-19: 155 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-19–2026-08-192026-08-20: 53 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-20–2026-08-202026-08-21: 45 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-21–2026-08-212026-08-22: 38 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-22–2026-08-222026-08-23: 39 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-23–2026-08-232026-08-24: 30 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-24–2026-08-242026-08-25: 31 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-25–2026-08-252026-08-26: 25 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-26–2026-08-262026-08-27: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-27–2026-08-272026-08-28: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-28–2026-08-282026-08-29: 11 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-29–2026-08-292026-08-30: 15 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-30–2026-08-302026-08-31: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-08-31–2026-08-312026-09-01: 10 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-01–2026-09-012026-09-02: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-02–2026-09-022026-09-03: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-03–2026-09-032026-09-04: 29 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-04–2026-09-042026-09-05: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-05–2026-09-052026-09-06: 8 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-06–2026-09-062026-09-07: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-07–2026-09-072026-09-08: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-08–2026-09-082026-09-09: 12 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-09–2026-09-092026-09-10: 8 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-10–2026-09-102026-09-11: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-11–2026-09-112026-09-12: 16 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-12–2026-09-122026-09-13: 8 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-13–2026-09-132026-09-14: 10 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-14–2026-09-142026-09-15: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-15–2026-09-152026-09-16: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-16–2026-09-162026-09-17: 45 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-17–2026-09-172026-09-18: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-18–2026-09-182026-09-19: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-19–2026-09-192026-09-20: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-20–2026-09-202026-09-21: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-21–2026-09-212026-09-22: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-22–2026-09-222026-09-23: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-23–2026-09-232026-09-24: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-24–2026-09-242026-09-25: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-25–2026-09-252026-09-26: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-26–2026-09-262026-09-27: 8 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-27–2026-09-272026-09-28: 8 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-28–2026-09-282026-09-29: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-29–2026-09-292026-09-30: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-09-30–2026-09-302026-10-01: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-01–2026-10-012026-10-02: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-02–2026-10-022026-10-03: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-03–2026-10-032026-10-04: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-04–2026-10-042026-10-05: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-05–2026-10-052026-10-06: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-06–2026-10-062026-10-07: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-07–2026-10-072026-10-08: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-08–2026-10-082026-10-09: 5 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-09–2026-10-092026-10-10: 7 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-10–2026-10-102026-10-11: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-11–2026-10-112026-10-12: 4 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-12–2026-10-122026-10-13: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-13–2026-10-132026-10-14: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-14–2026-10-142026-10-15: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-15–2026-10-152026-10-16: 6 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-16–2026-10-162026-10-17: 9 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-17–2026-10-172026-10-18: 11 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-18–2026-10-182026-10-19: 0 · observed 2026-10-20T21:34:23.0536876Z · period 2026-10-19–2026-10-19
22 Jul19 Oct

npm · 90 observations shown. Missing days are unknown.

View observed values
Date / source periodValueObserved at
2026-10-19 – 2026-10-1902026-10-20T21:34:23.0536876Z
2026-10-18 – 2026-10-18112026-10-20T21:34:23.0536876Z
2026-10-17 – 2026-10-1792026-10-20T21:34:23.0536876Z
2026-10-16 – 2026-10-1662026-10-20T21:34:23.0536876Z
2026-10-15 – 2026-10-1502026-10-20T21:34:23.0536876Z
2026-10-14 – 2026-10-1402026-10-20T21:34:23.0536876Z
2026-10-13 – 2026-10-1302026-10-20T21:34:23.0536876Z
2026-10-12 – 2026-10-1242026-10-20T21:34:23.0536876Z
2026-10-11 – 2026-10-1162026-10-20T21:34:23.0536876Z
2026-10-10 – 2026-10-1072026-10-20T21:34:23.0536876Z
2026-10-09 – 2026-10-0952026-10-20T21:34:23.0536876Z
2026-10-08 – 2026-10-0872026-10-20T21:34:23.0536876Z
2026-10-07 – 2026-10-0742026-10-20T21:34:23.0536876Z
2026-10-06 – 2026-10-0602026-10-20T21:34:23.0536876Z
2026-10-05 – 2026-10-0502026-10-20T21:34:23.0536876Z
2026-10-04 – 2026-10-0452026-10-20T21:34:23.0536876Z
2026-10-03 – 2026-10-0372026-10-20T21:34:23.0536876Z
2026-10-02 – 2026-10-0252026-10-20T21:34:23.0536876Z
2026-10-01 – 2026-10-0152026-10-20T21:34:23.0536876Z
2026-09-30 – 2026-09-3042026-10-20T21:34:23.0536876Z
2026-09-29 – 2026-09-2952026-10-20T21:34:23.0536876Z
2026-09-28 – 2026-09-2882026-10-20T21:34:23.0536876Z
2026-09-27 – 2026-09-2782026-10-20T21:34:23.0536876Z
2026-09-26 – 2026-09-2662026-10-20T21:34:23.0536876Z
2026-09-25 – 2026-09-2592026-10-20T21:34:23.0536876Z
2026-09-24 – 2026-09-2462026-10-20T21:34:23.0536876Z
2026-09-23 – 2026-09-2372026-10-20T21:34:23.0536876Z
2026-09-22 – 2026-09-2262026-10-20T21:34:23.0536876Z
2026-09-21 – 2026-09-2162026-10-20T21:34:23.0536876Z
2026-09-20 – 2026-09-2072026-10-20T21:34:23.0536876Z
2026-09-19 – 2026-09-1992026-10-20T21:34:23.0536876Z
2026-09-18 – 2026-09-1892026-10-20T21:34:23.0536876Z
2026-09-17 – 2026-09-17452026-10-20T21:34:23.0536876Z
2026-09-16 – 2026-09-1672026-10-20T21:34:23.0536876Z
2026-09-15 – 2026-09-1502026-10-20T21:34:23.0536876Z
2026-09-14 – 2026-09-14102026-10-20T21:34:23.0536876Z
2026-09-13 – 2026-09-1382026-10-20T21:34:23.0536876Z
2026-09-12 – 2026-09-12162026-10-20T21:34:23.0536876Z
2026-09-11 – 2026-09-1172026-10-20T21:34:23.0536876Z
2026-09-10 – 2026-09-1082026-10-20T21:34:23.0536876Z
2026-09-09 – 2026-09-09122026-10-20T21:34:23.0536876Z
2026-09-08 – 2026-09-0802026-10-20T21:34:23.0536876Z
2026-09-07 – 2026-09-0702026-10-20T21:34:23.0536876Z
2026-09-06 – 2026-09-0682026-10-20T21:34:23.0536876Z
2026-09-05 – 2026-09-0592026-10-20T21:34:23.0536876Z
2026-09-04 – 2026-09-04292026-10-20T21:34:23.0536876Z
2026-09-03 – 2026-09-0302026-10-20T21:34:23.0536876Z
2026-09-02 – 2026-09-0272026-10-20T21:34:23.0536876Z
2026-09-01 – 2026-09-01102026-10-20T21:34:23.0536876Z
2026-08-31 – 2026-08-3172026-10-20T21:34:23.0536876Z
2026-08-30 – 2026-08-30152026-10-20T21:34:23.0536876Z
2026-08-29 – 2026-08-29112026-10-20T21:34:23.0536876Z
2026-08-28 – 2026-08-2842026-10-20T21:34:23.0536876Z
2026-08-27 – 2026-08-2762026-10-20T21:34:23.0536876Z
2026-08-26 – 2026-08-26252026-10-20T21:34:23.0536876Z
2026-08-25 – 2026-08-25312026-10-20T21:34:23.0536876Z
2026-08-24 – 2026-08-24302026-10-20T21:34:23.0536876Z
2026-08-23 – 2026-08-23392026-10-20T21:34:23.0536876Z
2026-08-22 – 2026-08-22382026-10-20T21:34:23.0536876Z
2026-08-21 – 2026-08-21452026-10-20T21:34:23.0536876Z
2026-08-20 – 2026-08-20532026-10-20T21:34:23.0536876Z
2026-08-19 – 2026-08-191552026-10-20T21:34:23.0536876Z
2026-08-18 – 2026-08-1812026-10-20T21:34:23.0536876Z
2026-08-17 – 2026-08-1732026-10-20T21:34:23.0536876Z
2026-08-16 – 2026-08-1602026-10-20T21:34:23.0536876Z
2026-08-15 – 2026-08-1542026-10-20T21:34:23.0536876Z
2026-08-14 – 2026-08-1402026-10-20T21:34:23.0536876Z
2026-08-13 – 2026-08-1302026-10-20T21:34:23.0536876Z
2026-08-12 – 2026-08-1232026-10-20T21:34:23.0536876Z
2026-08-11 – 2026-08-1112026-10-20T21:34:23.0536876Z
2026-08-10 – 2026-08-1082026-10-20T21:34:23.0536876Z
2026-08-09 – 2026-08-0912026-10-20T21:34:23.0536876Z
2026-08-08 – 2026-08-0862026-10-20T21:34:23.0536876Z
2026-08-07 – 2026-08-0732026-10-20T21:34:23.0536876Z
2026-08-06 – 2026-08-0632026-10-20T21:34:23.0536876Z
2026-08-05 – 2026-08-0522026-10-20T21:34:23.0536876Z
2026-08-04 – 2026-08-0462026-10-20T21:34:23.0536876Z
2026-08-03 – 2026-08-0302026-10-20T21:34:23.0536876Z
2026-08-02 – 2026-08-0292026-10-20T21:34:23.0536876Z
2026-08-01 – 2026-08-0152026-10-20T21:34:23.0536876Z
2026-07-31 – 2026-07-3112026-10-20T21:34:23.0536876Z
2026-07-30 – 2026-07-3032026-10-20T21:34:23.0536876Z
2026-07-29 – 2026-07-2912026-10-20T21:34:23.0536876Z
2026-07-28 – 2026-07-2822026-10-20T21:34:23.0536876Z
2026-07-27 – 2026-07-2772026-10-20T21:34:23.0536876Z
2026-07-26 – 2026-07-2642026-10-20T21:34:23.0536876Z
2026-07-25 – 2026-07-2542026-10-20T21:34:23.0536876Z
2026-07-24 – 2026-07-2452026-10-20T21:34:23.0536876Z
2026-07-23 – 2026-07-2392026-10-20T21:34:23.0536876Z
2026-07-22 – 2026-07-2272026-10-20T21:34:23.0536876Z

Versions 3

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.2Registry latest19 Aug 20262
1.0.119 Jul 20262
1.0.08 Jul 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
easierbycode/svelte-phaser

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:40 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:bbd520aa99b4f2fa16f84fc5591faf3c78c164843e105652bcd95c9be0f948c7