This repository was archived by the owner on Oct 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Adding svelte helper #1172
Open
shiftlabs1
wants to merge
19
commits into
rivet-dev:main
Choose a base branch
from
joshua1:adding-svelte-helper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adding svelte helper #1172
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
be4527b
create svelte helper module using svelte 5 runes
joshua1 9a12679
Merge branch 'main' into adding-svelte-helper
joshua1 1a7b324
so far on svelte
joshua1 a9d7782
unignore pnpm-lock
joshua1 8a5487a
Merge branch 'main' into adding-svelte-helper
joshua1 c479a95
completed,cleanup on the way
joshua1 c822e9d
cleanup useEvent in effect hook
joshua1 8781746
add previous state to type definition
joshua1 18e6f11
update cursor rules and openAPI spec
joshua1 52520ef
merge onStatChange modifications
joshua1 7dce6a7
update readme
joshua1 9777f5f
send dist through for now
joshua1 27ca702
new actor build
joshua1 dfd5929
update to rivetkit-svelte
joshua1 0faf1df
update to rivetkit-svelte
joshua1 729aef4
Merge branch 'rivet-gg:main' into main
joshua1 85e765b
# Conflicts:
joshua1 9a4591c
merge conflict
joshua1 61e5125
latest merge
joshua1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| node_modules | ||
|
|
||
| # Output | ||
| .output | ||
| .vercel | ||
| .netlify | ||
| .wrangler | ||
| /.svelte-kit | ||
| /build | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Env | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
| !.env.test | ||
|
|
||
| # Vite | ||
| vite.config.js.timestamp-* | ||
| vite.config.ts.timestamp-* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| engine-strict=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # sv | ||
|
|
||
| Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). | ||
|
|
||
| ## Creating a project | ||
|
|
||
| If you're seeing this, you've probably already done this step. Congrats! | ||
|
|
||
| ```sh | ||
| # create a new project in the current directory | ||
| npx sv create | ||
|
|
||
| # create a new project in my-app | ||
| npx sv create my-app | ||
| ``` | ||
|
|
||
| ## Developing | ||
|
|
||
| Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: | ||
|
|
||
| ```sh | ||
| npm run dev | ||
|
|
||
| # or start the server and open the app in a new browser tab | ||
| npm run dev -- --open | ||
| ``` | ||
|
|
||
| ## Building | ||
|
|
||
| To create a production version of your app: | ||
|
|
||
| ```sh | ||
| npm run build | ||
| ``` | ||
|
|
||
| You can preview the production build with `npm run preview`. | ||
|
|
||
| > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { registry } from "./registry"; | ||
|
|
||
| export type Registry = typeof registry; | ||
|
|
||
| registry.runServer({ | ||
| cors: { | ||
| origin: "http://localhost:5173", | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { actor, setup } from "@rivetkit/actor"; | ||
|
|
||
| export const counter = actor({ | ||
| onAuth: () => { | ||
| // Configure auth here | ||
| }, | ||
| state: { count: 0 }, | ||
| actions: { | ||
| increment: (c, x: number) => { | ||
| console.log("incrementing by", x); | ||
| c.state.count += x; | ||
| c.broadcast("newCount", c.state.count); | ||
| return c.state.count; | ||
| }, | ||
| reset: (c) => { | ||
| c.state.count = 0; | ||
| c.broadcast("newCount", c.state.count); | ||
| return c.state.count; | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const registry = setup({ | ||
| use: { counter }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "name": "svelte-rivetkit-example", | ||
| "private": true, | ||
| "version": "0.0.1", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "run-p dev:web dev:api", | ||
| "dev:web": "vite dev", | ||
| "dev:api": "tsx --watch backend/index.ts", | ||
| "build": "vite build", | ||
| "preview": "vite preview", | ||
| "prepare": "svelte-kit sync || echo ''", | ||
| "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
| "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" | ||
| }, | ||
| "devDependencies": { | ||
| "@rivetkit/actor": "workspace:*", | ||
| "@rivetkit/svelte": "workspace:*", | ||
| "@sveltejs/adapter-auto": "^6.0.0", | ||
| "@sveltejs/kit": "^2.22.0", | ||
| "@sveltejs/vite-plugin-svelte": "^6.0.0", | ||
| "@types/node": "^22.13.9", | ||
| "svelte": "^5.0.0", | ||
| "svelte-check": "^4.0.0", | ||
| "typescript": "^5.0.0", | ||
| "vite": "^7.0.4", | ||
| "npm-run-all": "^4.1.5", | ||
| "tsx": "^3.12.7" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // See https://svelte.dev/docs/kit/types#app.d.ts | ||
| // for information about these interfaces | ||
| declare global { | ||
| namespace App { | ||
| // interface Error {} | ||
| // interface Locals {} | ||
| // interface PageData {} | ||
| // interface PageState {} | ||
| // interface Platform {} | ||
| } | ||
| } | ||
|
|
||
| export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| %sveltekit.head% | ||
| </head> | ||
| <body data-sveltekit-preload-data="hover"> | ||
| <div style="display: contents">%sveltekit.body%</div> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { createClient, createRivetKit } from "@rivetkit/svelte"; | ||
| import type { Registry } from "../../backend"; | ||
|
|
||
| const client = createClient<Registry>(`http://localhost:8080`); | ||
| export const { useActor } = createRivetKit(client); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // place files you want to import through the `$lib` alias in this folder. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const ssr = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <script lang="ts"> | ||
| import favicon from '$lib/assets/favicon.svg'; | ||
| let { children } = $props(); | ||
| </script> | ||
|
|
||
| <svelte:head> | ||
| <link rel="icon" href={favicon} /> | ||
| </svelte:head> | ||
|
|
||
| {@render children?.()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <script lang="ts"> | ||
| import { useActor } from "../lib/actor-client"; | ||
|
|
||
| let eventSub: any; | ||
| let count = $state(0); | ||
| const counter = useActor({ name: 'counter', key: ['test-counter'] }); | ||
|
|
||
| $effect(()=>{ | ||
| console.log('status', counter?.isConnected); | ||
| eventSub=counter?.useEvent('newCount', (x: number) => { | ||
| console.log('new count event', x); | ||
| count=x; | ||
| }); | ||
| return () => { | ||
| eventSub?.unsubscribe(); | ||
| }; | ||
| //also works | ||
| // counter.connection?.on('newCount', (x: number) => { | ||
| // console.log('new count event', x); | ||
| // count=x; | ||
| // }) | ||
| }) | ||
| const increment = () => { | ||
| counter?.connection?.increment(1); | ||
|
|
||
| }; | ||
| const reset = () => { | ||
| counter?.connection?.reset(); | ||
|
|
||
| }; | ||
|
|
||
| // $inspect is for debugging, but ensure it's used correctly | ||
| $inspect('useActor is connected', counter?.isConnected); | ||
| </script> | ||
|
|
||
| <div> | ||
| <h1>Counter: {count}</h1> | ||
| <button onclick={increment}>Increment</button> | ||
| <button onclick={reset}>Reset</button> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # allow crawling everything by default | ||
| User-agent: * | ||
| Disallow: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import adapter from "@sveltejs/adapter-auto"; | ||
| import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; | ||
|
|
||
| /** @type {import('@sveltejs/kit').Config} */ | ||
| const config = { | ||
| // Consult https://svelte.dev/docs/kit/integrations | ||
| // for more information about preprocessors | ||
| preprocess: vitePreprocess(), | ||
|
|
||
| kit: { | ||
| // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. | ||
| // If your environment is not supported, or you settled on a specific environment, switch out the adapter. | ||
| // See https://svelte.dev/docs/kit/adapters for more information about adapters. | ||
| adapter: adapter(), | ||
| alias: { | ||
| $: "./src", | ||
| "$/*": "./src/*", | ||
| $backend: "./backend", | ||
| "$backend/*": "./backend/*", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "extends": "./.svelte-kit/tsconfig.json", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "skipLibCheck": true, | ||
| "sourceMap": true, | ||
| "strict": true, | ||
| "moduleResolution": "bundler", | ||
| "baseUrl": "./", | ||
| "paths": { | ||
| "$/": ["./src/"], | ||
| "$backend/": ["./backend/"] | ||
| } | ||
| } | ||
| // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias | ||
| // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files | ||
| // | ||
| // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes | ||
| // from the referenced tsconfig.json - TypeScript does not merge them in | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "$schema": "https://turbo.build/schema.json", | ||
| "extends": ["//"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { sveltekit } from "@sveltejs/kit/vite"; | ||
| import { defineConfig } from "vite"; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [sveltekit()], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,5 +37,10 @@ | |
| "@hono/node-ws": "^1.1.7", | ||
| "esbuild": "^0.25.1" | ||
| }, | ||
| "packageManager": "[email protected]+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808" | ||
| "packageManager": "[email protected]+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808", | ||
| "pnpm": { | ||
| "onlyBuiltDependencies": [ | ||
| "esbuild" | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }// src/client.ts | ||
| var _client = require('@rivetkit/core/client'); _createStarExport(_client); | ||
| //# sourceMappingURL=client.cjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export * from '@rivetkit/core/client'; | ||
| import '@rivetkit/core/errors'; | ||
| import '@rivetkit/core/log'; | ||
| import '@rivetkit/core'; | ||
| import '@rivetkit/core/test'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export * from "@rivetkit/core/client"; | ||
| import "@rivetkit/core/errors"; | ||
| import "@rivetkit/core/log"; | ||
| import "@rivetkit/core"; | ||
| import "@rivetkit/core/test"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }// src/errors.ts | ||
| var _errors = require('@rivetkit/core/errors'); _createStarExport(_errors); | ||
| //# sourceMappingURL=errors.cjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from '@rivetkit/core/errors'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
onStateChangefunction signature has been updated to includeprevState, but there's a spacing inconsistency in the documentation. For consistency with other function signatures in this file, a space should be added after the first comma:Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.