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

metagame-sdk

v0.1.26

Published

A JavaScript/TypeScript SDK for interacting with Metagame components in Dojo.

Downloads

823

Readme

Metagame SDK

A JavaScript/TypeScript SDK for interacting with Metagame components in Dojo.

🚀 Quick Start

Installation

bun add metagame-sdk
# or
npm install metagame-sdk

Basic Setup

import { initMetagame, MetagameProvider } from 'metagame-sdk';

// Initialize the SDK (no provider required!)
const metagameClient = await initMetagame({
  toriiUrl: 'http://localhost:8080',
  worldAddress: '0x...', // Your world contract address
});

// Wrap your app with the provider
function App() {
  return (
    <MetagameProvider metagameClient={metagameClient}>
      <YourApp />
    </MetagameProvider>
  );
}

📦 Package Structure

The SDK is organized with modular imports for better tree-shaking and separation of concerns:

🎯 Core Package (Root Level)

Essential setup functions and types:

import { 
  // Setup functions
  initMetagame, 
  MetagameClient, 
  MetagameProvider,
  
  // Essential types
  GameTokenData,
  GameMetadata,
  MetagameConfig,
  
  // Utilities
  feltToString,
  stringToFelt
} from 'metagame-sdk';

🔄 Subscription Hooks (Real-time Data)

For live data that updates automatically:

import { 
  useSubscribeGameTokens, 
  useSubscribeMiniGames, 
  useSubscribeSettings, 
  useSubscribeObjectives 
} from 'metagame-sdk/subscriptions';

📊 SQL Hooks (Static Queries)

For one-time data fetching:

import { 
  useGameTokens,
  useMiniGames,
  useSettings,
  useObjectives 
} from 'metagame-sdk/sql';

🛠️ Advanced Utilities

For custom data processing:

import { 
  mergeGameEntities, 
  parseContextData,
  parseSettingsData,
  MetagameClient 
} from 'metagame-sdk/shared';

🎮 Usage Examples

Real-time Game Tokens

import { useSubscribeGameTokens } from 'metagame-sdk/subscriptions';

function GameTokensList() {
  const { games, isSubscribing, pagination } = useSubscribeGameTokens({
    owner: '0x123...',
    pagination: {
      pageSize: 10,
      sortBy: 'score',
      sortOrder: 'desc'
    }
  });

  if (isSubscribing) return <div>Loading...</div>;

  return (
    <div>
      {games.map(game => (
        <div key={game.token_id}>
          <h3>Token #{game.token_id}</h3>
          <p>Score: {game.score}</p>
          <p>Player: {game.player_name}</p>
        </div>
      ))}
    </div>
  );
}

Static Data Queries

import { useGameTokens } from 'metagame-sdk/sql';

function GameTokensQuery() {
  const { data: games, loading, error } = useGameTokens({
    owner: '0x123...',
    limit: 50
  });

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <div>
      {games.map(game => (
        <div key={game.token_id}>
          Token #{game.token_id} - Score: {game.score}
        </div>
      ))}
    </div>
  );
}

🔧 Configuration Options

const metagameClient = await initMetagame({
  // Required
  toriiUrl: 'http://localhost:8080',
  
  // For automatic dojoSDK creation
  worldAddress: '0x...', // Your world contract address
  
  // Optional
  relayUrl: 'http://localhost:9090',
  namespace: 'your_namespace_0_0_1',
  domain: {
    name: 'CUSTOM_WORLD',
    version: '1.0',
    chainId: 'KATANA',
    revision: '1'
  },
  
  // Advanced: Provide your own dojoSDK instance
  dojoSDK: yourDojoSDK,
  toriiClient: yourToriiClient
});

✨ Key Benefits

  • 🚫 No Provider Required: Simplified setup without Starknet provider dependency
  • 🌳 Tree Shaking: Import only what you need with modular structure
  • 🔄 Real-time & Static: Choose between live subscriptions or one-time queries
  • 📱 React Ready: Built-in hooks and provider for React applications
  • 🎯 Type Safe: Full TypeScript support with comprehensive type definitions
  • ⚡ Performance: Optimized data fetching and caching

📚 API Reference

Core Functions

  • initMetagame(config) - Initialize the SDK
  • getMetagameClient() - Get the initialized client instance
  • resetMetagame() - Reset the SDK (useful for testing)

Hook Categories

  • Subscriptions: Real-time data with automatic updates
  • SQL: Static queries for one-time data fetching
  • Shared: Utilities and advanced data processing

Types

  • GameTokenData - Complete game token information
  • GameMetadata - Mini game metadata
  • GameSettings - Game configuration settings
  • MetagameConfig - SDK configuration options

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

MIT License - see LICENSE for details.