
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
loro-mirror-jotai
Advanced tools
Jotai atoms for Loro Mirror: CRDT-backed atomic state with typed schema and bidirectional sync.
Jotai integration for Loro Mirror, providing atomic state management with Loro CRDT synchronization.
# Using pnpm
pnpm add loro-mirror-jotai jotai loro-crdt
# Using npm
npm install loro-mirror-jotai jotai loro-crdt
# Using yarn
yarn add loro-mirror-jotai jotai loro-crdt
Create a loroMirrorAtom to represent your shared state. It syncs automatically
with the provided Loro document.
import { useAtom } from 'jotai';
import { LoroDoc } from 'loro-crdt';
import { schema } from 'loro-mirror';
import { loroMirrorAtom } from 'loro-mirror-jotai';
type TodoStatus = "todo" | "inProgress" | "done";
const todoSchema = schema.LoroMap(
{
text: schema.String(),
status: schema.String<TodoStatus>()
}
)
// Define your schema
const todoDocSchema = schema({
todos: schema.LoroList(
todoSchema,
(t) => t.$cid, // stable LoroMap id from Loro container id
)
});
// Auto generated type from schema
type Todo = InferType<typeof todoSchema>;
// Create a Loro document instance
const doc = new LoroDoc();
// Maybe subscribe the doc for persisting
let sub = doc.subscribe(......)
// Create the Jotai atom with Loro Mirror config
const todoDocAtom = loroMirrorAtom({
doc,
schema: todoDocSchema,
initialState: { todos: [] as Todo[] },
});
// Selector atom
const todosAtom = atom(get => get(todoDocAtom).todos, (_get, set, todos: Todo[]) => {
set(todoDocAtom, { todos })
})
// Action atom
const addTodoAtom = atom(null, (get, set, todo: Todo) => {
set(todosAtom, [...get(todosAtom), todo])
})
// Use it in your React component
function TodoApp() {
const todos = useAtomValue(todosAtom);
const addTodo = useSetAtom(addTodoAtom);
return (
<div>
<button onClick={()=>{
addTodo({text: "New todo", status: "todo"})
}}>Add Todo</button>
<ul>
{state.todos.map((todo) => (
<li key={todo.$cid /* stable key from Loro container id */}>
{todo.text}: {todo.status}
</li>
))}
</ul>
</div>
);
}
$cid$cid is always present on LoroMap state and equals the underlying Loro
container id.$cid as a stable list selector and React key:
schema.LoroList(item, x => x.$cid) and <li key={todo.$cid}>.FAQs
Jotai atoms for Loro Mirror: CRDT-backed atomic state with typed schema and bidirectional sync.
We found that loro-mirror-jotai demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.