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

@sylphx/rosetta-admin

v0.3.10

Published

Headless translation admin hooks for @sylphx/rosetta

Readme

@sylphx/rosetta-admin

Headless translation admin hooks for @sylphx/rosetta.

Features

  • Pure Hooks - No UI components, just logic. Build your own UI with your existing design system.
  • Framework-Agnostic Core - Vanilla TypeScript store, ready for React/Vue/Solid adapters.
  • tRPC & REST - First-class support for both tRPC and REST APIs.
  • AI Translation - Built-in OpenRouter and Anthropic translators.
  • Source Override - English text can be overridden in DB (CMS mode).
  • Staleness Detection - Know when translations are outdated.

Installation

npm install @sylphx/rosetta-admin
# or
bun add @sylphx/rosetta-admin

Quick Start

1. Server Setup (tRPC)

// server/trpc/routers/admin.ts
import { createAdminRouter } from '@sylphx/rosetta-admin/server/trpc';
import { storage } from '@/lib/rosetta';
import { createOpenRouterTranslator } from '@sylphx/rosetta-admin/ai';

export const adminRouter = createAdminRouter({
  storage,
  translator: createOpenRouterTranslator({
    apiKey: process.env.OPENROUTER_API_KEY!,
    model: 'anthropic/claude-sonnet-4',
  }),
});

// Merge into your app router
export const appRouter = router({
  admin: adminRouter,
});

2. Client Setup

// app/admin/translations/page.tsx
'use client';
import {
  TranslationAdminProvider,
  useTranslationAdmin,
  createTRPCClient,
} from '@sylphx/rosetta-admin/react';
import { api } from '@/trpc/react';

const client = createTRPCClient(api.admin);

function TranslationDashboard() {
  const {
    locales,
    stats,
    view,
    activeLocale,
    enterEditor,
    exitEditor,
    getLocaleProgress,
  } = useTranslationAdmin();

  if (view === 'editor' && activeLocale) {
    return <TranslationEditor locale={activeLocale} onBack={exitEditor} />;
  }

  return (
    <div className="grid gap-4">
      {locales.map(locale => (
        <div key={locale} onClick={() => enterEditor(locale)}>
          <h3>{locale}</h3>
          <p>{getLocaleProgress(locale)}% translated</p>
        </div>
      ))}
    </div>
  );
}

export default function Page() {
  return (
    <TranslationAdminProvider client={client}>
      <TranslationDashboard />
    </TranslationAdminProvider>
  );
}

Hooks

useTranslationAdmin()

Main hook providing all state and actions:

const {
  // Data
  sources,           // All source strings with translations
  locales,           // Active locales
  stats,             // Translation statistics

  // View state
  view,              // 'dashboard' | 'editor'
  activeLocale,      // Currently editing locale
  filteredSources,   // Filtered by search/status

  // Editor state
  searchQuery,
  statusFilter,
  editingHash,

  // Loading
  isLoading,
  isBatchTranslating,
  batchProgress,
  error,

  // Actions
  enterEditor,       // (locale: string) => void
  exitEditor,        // () => void
  setSearchQuery,
  setStatusFilter,
  saveTranslation,   // (hash, text, locale?) => Promise
  markAsReviewed,    // (hash, locale?) => Promise
  batchTranslate,    // (locale?, hashes?) => Promise
  addLocale,
  removeLocale,
  refresh,

  // Helpers
  getLocaleProgress, // (locale) => number (0-100)
  getOutdatedCount,  // (locale) => number
} = useTranslationAdmin();

useTranslationEditor()

Focused hook for the editor view:

const {
  locale,
  sources,
  searchQuery,
  statusFilter,
  editingHash,
  isSaving,
  saveError,

  setSearchQuery,
  setStatusFilter,
  startEditing,
  cancelEditing,
  saveTranslation,
  markAsReviewed,
  getTranslation,
  getStatus,
} = useTranslationEditor();

useBatchTranslate()

Focused hook for batch AI translation:

const {
  isRunning,
  progress,
  error,
  untranslatedCount,
  translateAll,
  translateSelected,
} = useBatchTranslate();

REST API Setup

If you prefer REST over tRPC:

// app/api/admin/translations/route.ts
import { createRestHandlers } from '@sylphx/rosetta-admin/server';
import { storage } from '@/lib/rosetta';
import { createOpenRouterTranslator } from '@sylphx/rosetta-admin/ai';

const handlers = createRestHandlers({
  storage,
  translator: createOpenRouterTranslator({
    apiKey: process.env.OPENROUTER_API_KEY!,
  }),
  authorize: async (req) => {
    // Add your auth check
    return true;
  },
});

export const { GET, PUT, PATCH } = handlers;
// app/api/admin/translations/batch/route.ts
import { handlers } from '../route';
export const POST = handlers.batchTranslate;
// Client
import { createRestClient } from '@sylphx/rosetta-admin/react';

const client = createRestClient({ baseUrl: '/api/admin/translations' });

AI Translators

OpenRouter

import { createOpenRouterTranslator } from '@sylphx/rosetta-admin/ai';

const translator = createOpenRouterTranslator({
  apiKey: process.env.OPENROUTER_API_KEY!,
  model: 'anthropic/claude-sonnet-4', // default
  batchSize: 50,  // default
});

Anthropic (Direct)

import { createAnthropicTranslator } from '@sylphx/rosetta-admin/ai';

const translator = createAnthropicTranslator({
  apiKey: process.env.ANTHROPIC_API_KEY!,
  model: 'claude-sonnet-4-20250514',
});

Custom Translator

import type { TranslateFunction } from '@sylphx/rosetta-admin';

const myTranslator: TranslateFunction = async (items, locale) => {
  // Call your own API
  return items.map(item => ({
    sourceHash: item.sourceHash,
    translatedText: await myCustomAPI(item.sourceText, locale),
  }));
};

Package Exports

// Core types and store
import { ... } from '@sylphx/rosetta-admin';

// React hooks and context
import { ... } from '@sylphx/rosetta-admin/react';

// Server-side (service + REST handlers)
import { ... } from '@sylphx/rosetta-admin/server';

// tRPC router
import { ... } from '@sylphx/rosetta-admin/server/trpc';

// AI translators
import { ... } from '@sylphx/rosetta-admin/ai';

License

MIT