pluv.io allows you to more easily build realtime multiplayer experiences with a fully typesafe API and powerful abstractions as primitives, so that you can focus on building for your end users.
Self-host on Cloudflare Workers or Node.js; or get started on the pluv.io network.
Create your pluv.io backend
// backend const io = createIO( platformNode({ context: () => ({ db }), crdt: yjs, }) ); export const ioServer = io.server({ getInitialStorage: async ({ context: { db }, room }) => { return await db.room .findUnique({ where: { id: room } }) .then((result) => result?.encodedState ?? null); }, router: io.router({ sendGreeting: io.procedure .input(z.object({ message: z.string() })) .broadcast(({ message }) => ({ receiveGreeting: { message } })) }) });
Create your frontend client with your backend types
// frontend const types = infer((i) => ({ io: i<typeof ioServer> })); const io = createClient({ types, initialStorage: yjs.doc((t) => ({ messages: t.array<string>("messages"), })), presence: z.object({ selectionId: z.string().nullable() }) }); const { event, useBroadcast, useMyPresence, useOthers, useStorage } = createBundle(io);
Use powerful primitives to build realtime features
// react event.receiveGreeting.useEvent(({ data }) => { /* ... */}); // ^? const data: { message: string } const broadcast = useBroadcast(); broadcast.sendGreeting({ message: "hello world" }); // ^? const sendGreeting: (data: { message: string }) => void const [mySelection, update] = useMyPresence((presence) => { // ^? const mySelection: string | null return presence.selectionId; }); const others = useOthers((others) => { // ^? const others = string[] return others.map((other) => other.presence.selectionId); }); const [ messages, // ^? const messages: string[] | null sharedType // ^? YArray<string> | null ] = useStorage("messages");
The full documentation is available at pluv.io.
This software uses the following open source tooling and libraries:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4