LiveSolidJS

Bring the power of SolidJS to Phoenix LiveView - seamless client-side interactivity with server-side state management.

SolidJS 为 Phoenix LiveView 提供高效的、细粒度响应式的前端框架集成。

Key Features

Documentation

Examples

The live_solidjs_examples project includes:

Each example is fully documented with explanation of SolidJS patterns and live_solidjs integration points.

Why LiveSolidJS?

Phoenix LiveView enables rich, real-time user experiences with server-rendered HTML and WebSocket communication. LiveSolidJS extends this by adding powerful client-side interactivity:

The Problem with Traditional React in LiveView

Why SolidJS is Different

  1. Fine-grained Reactivity: Instead of re-rendering entire component trees, SolidJS tracks individual value changes and updates only the affected DOM nodes
  2. No Virtual DOM: SolidJS compiles directly to optimized vanilla JavaScript, resulting in:
    • Smaller bundle sizes (20KB vs 40KB+ for React)
    • Faster execution
    • Better performance on mobile devices
  3. Reactive Props: Props are automatically reactive through SolidJS stores, so components respond instantly to LiveView updates without manual optimization
  4. Better Developer Experience: Closer to vanilla JavaScript with minimal abstractions

Real-World Use Cases

Quick Start

See QUICK_START.md for step-by-step setup instructions.

Or explore the live_solidjs_examples project to see it in action.

Important Notes

Props Handling (Critical!)

When accessing props in your SolidJS components, always use props.field syntax and avoid destructuring in the function signature:

// ✅ Correct - Props stay reactive
export function Component(props) {
  return <div>{props.value}</div>;
}

// ❌ Wrong - Props lose reactivity
export function Component({ value }) {
  return <div>{value}</div>;
}

See QUICK_START.md - Reactive Props for more details.

Windows Users

推荐:在 config/dev.exs 中配置 watchers,使用 cmd 运行 npm 命令,这样 mix phx.server 时 Vite 会自动启动:

# config/dev.exs
config :my_app, MyAppWeb.Endpoint,
  watchers: [
    cmd: ["/c", "npm", "run", "dev", cd: Path.expand("../assets", __DIR__)]
  ]

启动服务器时以管理员身份运行终端以支持符号链接(symlink):

mix phx.server  # Vite 会自动启动

更多详情见 Installation Guide - Windows Users

Streams Support

Phoenix Streams are fully supported for efficient real-time list updates. See GEMINI.md - Streams Bug Fix for implementation details.

Contributing

Contributions are welcome! Please refer to IMPLEMENTATION_SUMMARY.md for technical details on the project architecture.

External Resources

Credits

Inspired by the following libraries:

License

MIT License - See LICENSE.md for details