
Security News
crates.io Ships Security Tab and Tightens Publishing Controls
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.
@rubriclab/state
Advanced tools
A lightweight, real-time state management library for Next.js applications with WebSocket support.
bun add @rubriclab/state
@rubriclab scope packages are not built, they are all raw TypeScript. If using in a Next.js app, make sure to transpile.
import type { NextConfig } from 'next'
export default {
transpilePackages: ['@rubriclab/state']
} satisfies NextConfig
If using inside the monorepo (@rubric), simply add
{"@rubriclab/state": "*"}to dependencies and then runbun i
To get started, define a few objects.
import { z } from 'zod/v4'
export const schema = z.object({
todos: z.record(z.string(), z.object({
title: z.string(),
completed: z.boolean()
})).default({})
})
The provider handles fetching initial data for first-paint (SSR)
import { RealtimeProvider } from '@rubriclab/state'
export default function Layout({ children }) {
return (
<RealtimeProvider websocketUrl="ws://localhost:3001">
{children}
</RealtimeProvider>
)
}
Pass your schema into the hook creator to get typesafe states.
import { createLiveState } from '@rubriclab/state/client'
const { useLiveState } = createLiveState(schema)
export function MyComponent() {
const [todos, setTodos] = useLiveState('todos')
const addTodo = () => {
setTodos(prev => ({
...prev,
[crypto.randomUUID()]: { title: 'New todo', completed: false }
}))
}
return (
<div>
<button onClick={addTodo} type="button">
Add Todo
</button>
<ul>
{Object.entries(todos).map(([id, todo]) => (
<li key={id}>
<input
type="checkbox"
checked={todo.completed}
onChange={() =>
setTodos(prev => ({
...prev,
[id]: { ...todo, completed: !todo.completed }
}))
}
/>
{todo.title}
</li>
))}
</ul>
</div>
)
}
Use it as you would useState.
Run bun run rubriclab-state-start to start the server.
The server can be deployed eg. on Railway by setting this as the custom start command.
To enable state persistence across server restarts, set the REDIS_URL environment variable:
REDIS_URL=redis://localhost:6379 bun run rubriclab-state-start
When Redis is configured:
state:{channelId}This is particularly useful for production deployments where you want state to survive server restarts.
Open your Next.js app in two browser windows. Values should be synced between the two.
Try disabling JS in one browser:
⌘+⇧+i > ⌘+⇧+p > disable j... > ⏎
then refreshing - the page should still reflect fresh data.
Start the WebSocket server:
bun dev
FAQs
Unknown package
We found that @rubriclab/state demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.

Research
/Security News
A Chrome extension claiming to hide Amazon ads was found secretly hijacking affiliate links, replacing creators’ tags with its own without user consent.

Security News
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.