@hivem/js
v0.1.3
Published
Pure TypeScript SDK for Hivem - auth-based KV service with sync support
Downloads
304
Maintainers
Readme
@hivem/js
- Pure typescript client
- default supports all js runtimes
- sse has support for all pure js clients plus reactnative specific tooling.
Methods
- This is the entire interface
- Each key gets identity scoping, so dont reinclude some identity prefix again.
- Backends API keys dont need signature, so just use empty fields
import { HivemClient } from '@hivem/js';
const client = new HivemClient({
baseUrl: 'https://api.example.com',
apiKey: 'BACKEND_API_KEY or FRONTEND_API_KEY'
});
// Sign an identity - (on your backend or authoritative server)
const { identity, signature } = await client.sign('user123');
// Get a value (frontend/backend)
const { key, value } = await client.get(identity, signature, 'my-key');
// Set a value (frontend/backend)
await client.set(identity, signature, 'my-key', 'my-value');
// Subscribe to changes (frontend/backend)
const { close } = client.subscribe(identity, signature, {
onMessage: (msg) => console.log(msg),
onError: (err) => console.error(err)
});