Welcome to Room Service!
This guide will walk you through setting up a todo list demo and go over a couple of key concepts to help you learn how to make multiplayer products.
First, grab an API key by setting up an account at app.roomservice.dev.
Create a new project by copying this command and pasting it into your terminal:
This will create a new project from the next.js-todolist example project.
yarn install or
npm install to install the dependencies.
pages/api/roomservice.js replace the placeholder API_KEY on line 3 with your own.
yarn dev or
npm run dev in your terminal to launch the product!
Open up the browser in two different windows and watch as the list updates in real time using the List data type.
Room Service provides a number of different data types which are the building blocks of multiplayer features.
Lists are an ordered collection of items, stored in a CRDT-like data structure. Lists can contain other lists and maps, resolve conflicts automatically, and do their best to preserve user intent while maintaining order.
A Map is a distributed key-value store. Maps can contain other maps or lists, resolve conflicts automatically, and update in real-time. When you update a map, it updates optimistically and forwards the message to everyone else in the room in the background.
With Presence, you can store a temporary string, boolean, number, or JSON object on a user. Use it to build mouse cursors, shared highlighting, draggable effects, or any other feature that doesn't require long-term persistence.
This demo project uses our React library in order to create and manipulate lists (and other data structures).
View the Lists docs to view the rest of the
Room Service uses your own authentication/authorization system. The client will send a
post request to your server, and you decide if that user is authorized or not.
For example, in our next.js todo demo our server is currently accepting post requests from our client. You can add in authorization by simply wrapping the fetch request in your authorization logic.