Skip to content

Example using Svelte 5 runes for state management #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

oliverturner
Copy link
Contributor

@oliverturner oliverturner commented Apr 27, 2025

Description

Demonstrates how the browser.storage API allows different parts of the extension share state and reflect activity on the current page.

  • The page at http://localhost:3000 fires a "counter:updated" event every second.
  • The Content Script handles these events by pushing the event payload into session storage.
  • The CounterState class watches the store and updates its reactive state property on change
  • App.svelte reflects the value of counterState.state

It's inspired by the existing Custom Svelte Store example, but using Svelte 5 and runes, addressing #14

Additionally demonstrates how to communicate with the active page.

Note

This PR updates the local versions of Vite and WXT, which triggers warnings for other examples expecting different versions. This issue is resolved by #22

@oliverturner oliverturner marked this pull request as ready for review April 27, 2025 18:37
@oliverturner oliverturner changed the title Add example for Svelte state management with WXT Example using Svelte 5 runes for state management Apr 27, 2025
Copy link
Contributor

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One small change and we'll get this merged.

Edit: Also looks like you need to fix conflicts in the lockfile. git fetch && git merge origin/main && git checkout origin/main pnpm-lock.yaml && pnpm i --ignore-scripts should do all that for you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this file. Looks like it's a leftover from running npm i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants