npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@workspace-fs/react

v1.0.1

Published

React hooks for Workspace-FS - Multi-project file system management

Downloads

12

Readme

@workspace-fs/react

React hooks for Workspace-FS - Multi-project file system management

npm version npm downloads License: MIT

Installation

npm install @workspace-fs/react @workspace-fs/core
# or
yarn add @workspace-fs/react @workspace-fs/core
# or
pnpm add @workspace-fs/react @workspace-fs/core

Key Concepts

The WorkspaceProvider requires a pre-configured WorkspaceFileSystem instance. You are responsible for:

  1. Creating the workspace instance
  2. Initializing it with your providers
  3. Passing it to the WorkspaceProvider

This gives you full control over the workspace configuration and lifecycle.

Quick Start

import { WorkspaceProvider, useWorkspace, useActiveProject } from '@workspace-fs/react';
import { WorkspaceFileSystem } from '@workspace-fs/core';
import { memoryProvider } from '@firesystem/memory/provider';
import { indexedDBProvider } from '@firesystem/indexeddb/provider';

// Create your workspace instance
const workspace = new WorkspaceFileSystem();

// Register your providers first
workspace.registerProvider(memoryProvider);
workspace.registerProvider(indexedDBProvider);

// Then initialize
await workspace.initialize();

function App() {
  return (
    <WorkspaceProvider workspace={workspace}>
      <Workspace />
    </WorkspaceProvider>
  );
}

function Workspace() {
  const { loadProject, setActiveProject } = useWorkspace();
  const { project, fs } = useActiveProject();
  
  const handleCreateProject = async () => {
    const project = await loadProject({
      id: `project-${Date.now()}`,
      name: 'My Project',
      source: { type: 'memory', config: {} }
    });
    await setActiveProject(project.id);
  };
  
  if (!fs) {
    return <button onClick={handleCreateProject}>Create Project</button>;
  }
  
  return (
    <div>
      <h1>{project?.name}</h1>
      {/* Use fs to read/write files */}
    </div>
  );
}

Available Hooks

Core Hooks

  • useWorkspace() - Main workspace management
  • useProjects() - Reactive list of all projects
  • useProject(id) - Access specific project by ID
  • useActiveProject() - Current active project with fs shortcut
  • useWorkspaceEvents(event, callback) - Listen to workspace events

Optimization Hooks

  • useProjectSelector(id, selector) - Select specific data from a project
  • useProjectsSelector(selector) - Select data from projects list
  • useActiveProjectSelector(selector) - Select data from active project

Examples

List All Projects

function ProjectList() {
  const { projects, activeProjectId } = useProjects();
  
  return (
    <ul>
      {projects.map(project => (
        <li key={project.id} className={project.id === activeProjectId ? 'active' : ''}>
          {project.name} ({project.source.type})
        </li>
      ))}
    </ul>
  );
}

Listen to File Changes

function FileWatcher() {
  useWorkspaceEvents('project:file:written', ({ projectId, path }) => {
    console.log(`File ${path} saved in project ${projectId}`);
  });
  
  return null;
}

Optimized Selectors

function ProjectName({ projectId }: { projectId: string }) {
  // Only re-renders when name changes, not on any project update
  const name = useProjectSelector(projectId, p => p?.name);
  
  return <span>{name}</span>;
}

Complete Example

import { WorkspaceProvider, useWorkspace, useProjects } from '@workspace-fs/react';
import { WorkspaceFileSystem } from '@workspace-fs/core';
import { memoryProvider } from '@firesystem/memory/provider';
import { indexedDBProvider } from '@firesystem/indexeddb/provider';

// Create and configure workspace outside of React
const workspace = new WorkspaceFileSystem();

// Initialize before rendering
async function initApp() {
  // Register providers
  workspace.registerProvider(memoryProvider);
  workspace.registerProvider(indexedDBProvider);
  
  // Initialize workspace
  await workspace.initialize();
  
  // Now render your app
  const root = ReactDOM.createRoot(document.getElementById('root'));
  root.render(
    <WorkspaceProvider workspace={workspace}>
      <App />
    </WorkspaceProvider>
  );
}

initApp();

API Reference

WorkspaceProvider

The context provider that makes the workspace available to all child components.

interface WorkspaceProviderProps {
  children: React.ReactNode;
  workspace: WorkspaceFileSystem; // Required - your configured workspace instance
}

Hooks

All hooks require the component to be wrapped in a WorkspaceProvider.

License

MIT