Skip to content

Solid's HMR does not persist the state, but other JS frameworks can. #2419

@Blankeos

Description

@Blankeos

Describe the bug

So I don't know why I just realized this now, I thought it was normal but out of React, Svelte, Vue, and Solid.
Only Svelte and Solid don't persist state between HMR updates.

Is it because Solid and Svelte have a "compiler"?

Edit: Interestingly I found something on why Svelte disables it and how to re-enable it: https://stackoverflow.com/questions/78013735/how-do-i-preserve-state-when-hot-reloading-in-a-standard-sveltekit-dev-environme. It's good that it's at least documented, but not sure for SolidJS.

Your Example Website or App

https://github.com/blankeos/solid-hmr-signal-bugs

Steps to Reproduce the Bug or Issue

To reproduce:

  1. Go to any project. cd <project>
  2. bun install then bun dev then open http://localhost:3000/
  3. Click on any "Counter", increase it (changes the state obviously).
  4. Now make a change on the code of the project, and press save.
  5. Results from testing:
  • ✅ react-vite - state is persisted
  • ✅ vue vite - state is persisted
  • ❌ solid-start - state is NOT persisted
  • ❌ solid-vike - state is NOT persisted
  • ❌ solid-vite - state is NOT persisted
  • ❌ svelte-vite - state is NOT persisted
  • ❌ svelte-kit - state is NOT persisted

Expected behavior

State is persisted (kinda useful when styling modals currently opened, making changes the component is in a specific state, etc.)

Screenshots or Videos

solid-signal-persist-hmr.mp4

Platform

  • OS: macOS
  • Browser: Arc (Chrome)
  • Version:
    • "solid-js": "^1.9.4"
    • "vite": "^6.0.11"

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions