@kokimoki/app
v3.1.6
Published
Kokimoki app
Readme
@kokimoki/app
The core SDK for building real-time multiplayer games with Kokimoki.
Installation
npm install @kokimoki/appQuick Start
import { getKmClient } from "@kokimoki/app";
const kmClient = getKmClient();
// Create a synchronized store
const gameStore = kmClient.store("game", {
players: {},
status: "waiting",
});
// Update state with transactions
await kmClient.transact([gameStore], ([state]) => {
state.players[kmClient.id] = { name: "Player 1", score: 0 };
});Features
- Real-time State Sync - Synchronized stores across all connected clients
- Dynamic Stores - Room-based state isolation for teams, chat, breakout rooms
- AI Services - Text and image generation
- Storage - File uploads to CDN
- i18n - Internationalization with AI-powered translation
- Leaderboards - Player rankings and scores
Documentation
See the docs folder for detailed instructions:
| File | Description | | ----------------------------------------------------------------------------------------- | --------------------------------------------- | | kokimoki-sdk.instructions.md | Core SDK usage (client, stores, transactions) | | kokimoki-dynamic-stores.instructions.md | Room-based state isolation | | kokimoki-ai.instructions.md | AI text and image generation | | kokimoki-storage.instructions.md | File storage and CDN uploads | | kokimoki-i18n.instructions.md | Internationalization | | kokimoki-leaderboard.instructions.md | Player rankings |
Usage with React
import { getKmClient, useSnapshot } from "@kokimoki/app";
const kmClient = getKmClient();
const gameStore = kmClient.store("game", { count: 0 });
function Counter() {
const { count } = useSnapshot(gameStore.proxy);
const increment = () => {
kmClient.transact([gameStore], ([state]) => {
state.count++;
});
};
return <button onClick={increment}>Count: {count}</button>;
}