@tanuden/kumoha-react
v0.4.2
Published
React hooks for Tanuden Kumoha theming engine
Readme
[!TIP] This documentation is available in English & Japanese このドキュメントは英語版と日本語版があります。
🪝 Available Hooks
useInitializeKumoha(uri, options?)Initializes the Kumoha engine. This must be called before using any other hook. Accepts an optional configuration including test data.useKumohaClientMeta()Provides real-time metadata about the client's connection status, current state, and login response.useKumohaData()Returns the current synced game state and data (KumohaArisuData).useKumoha()Exposes the underlyingKumohaengine instance. Useful for calling methods directly.This hook is especially important for users who want to use
sendButtonAction. Use of other internal engine functions is intended for advanced users familiar with the inner workings of@tanuden/kumoha.For more details, refer to the main Kumoha library on GitHub: @tanuden/kumoha
📦 Installation
Install @tanuden/kumoha-react and its required dependencies @tanuden/kumoha and opentetsu:
npm install @tanuden/kumoha @tanuden/kumoha-react
npm install opentetsu -DMake sure the packages are included in your project to ensure proper functionality.
⚙️ Usage
To get started, call useInitializeKumoha() at the top level of your component tree or inside a dedicated initialization component. All other hooks (useKumohaClientMeta, useKumohaData, and useKumoha) should only be used after initialization.
import {
useInitializeKumoha,
useKumohaClientMeta,
useKumohaData,
useKumoha,
} from '@tanuden/kumoha-react';
export const KumohaDemo = () => {
const kumoha = useInitializeKumoha(`http://${window.location.hostname}:58680`);
const clientMeta = useKumohaClientMeta();
const data = useKumohaData();
// If you want to call Kumoha methods directly in other components, you can use this:
// const kumoha = useKumoha();
return (
<div>
<p>Connected: {clientMeta.connected ? 'Yes' : 'No'}</p>
<p>Game state: {data.state}</p>
{/* Refer to the main Kumoha documentation for more details on sendButtonAction */}
<button onClick={() => kumoha.sendButtonAction('DoorOpn', 'pulse')}>Open Door</button>
</div>
);
};[!NOTE] Always call
useInitializeKumoha()before using any other hooks from this library.
💾 Tanuden OSS
This project is licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1). For more details, please see the LICENSE file.
[!IMPORTANT] This repository may contain trademarks or logos owned by Tanukigawa Railway. Unauthorized use is prohibited.
💝 Support
If you have some spare change you'll like to contribute to my ramen fund (helps keep me filled while working on projects), visit my Fanbox.
Tanuden Discord Server | Twitter | YouTube
Tanukigawa Electric Railway | Copyright © 2025 Haruyuki Tanukiji.
