Skip to main content
The @reatom/vue package provides Vue 3 integration for Reatom, allowing you to use atoms with Vue’s reactivity system through custom refs and composables.

Installation

This package requires Vue 3.5.17 or higher and is currently in alpha.

Setup

Provide the Reatom frame to your Vue application:

Core Composables

reatomRef

Convert Reatom atoms to Vue refs for seamless integration with Vue’s reactivity system:

Basic Usage

With Computed Atoms

Computed atoms return readonly refs:

With Inline Computed

You can also pass computed functions directly:
API Reference:
Features:
  • Automatic subscription management
  • Cleanup on component unmount
  • Full TypeScript support
  • Readonly refs for computed atoms

useAction

Wrap functions to execute them within the Reatom context:
Parameters:
  • fn: Function to wrap
Returns:
  • Wrapped function that executes in the Reatom context

useFrame

Access the current Reatom frame:

Complete Examples

Counter Application

Todo List

Form with Multiple Fields

TypeScript Support

The package is fully typed and works seamlessly with TypeScript:

Best Practices

1

Use reatomRef for atoms

Convert atoms to refs using reatomRef to integrate with Vue’s reactivity system.
2

Leverage computed atoms

Use Reatom’s computed atoms for derived state instead of Vue’s computed refs when you need cross-framework compatibility.
3

Wrap actions with useAction

Use useAction for event handlers to ensure they execute in the correct Reatom context.
4

Provide context at the app level

Set up the Reatom context once at the application root using createReatomVue.

SSR Support

For server-side rendering with Vue, ensure you create a new context per request:

Next Steps

  • Learn about Core Concepts for atoms and state management
  • Explore [Asynchttps://github.com/reatom/reatom/tree/main/packages for handling asynchronous operations
  • Check out [Persisthttps://github.com/reatom/reatom/tree/main/packages for state persistence