LiveKit LogoDocs

Quickstart Guides / Backend / Ruby

Ruby Backend Quickstart

On this page

1. Install Livekit Server SDK2. Keys and Configuration3. Make an endpoint that returns a token4. Create a client app to connect

1. Install Livekit Server SDK

Add this line to your application's Gemfile:

gem 'livekit-server-sdk'

Then run bundle install.

2. Keys and Configuration

Create a new file at development.env and with your API Key and Secret:

export LIVEKIT_API_KEY=<API Key>
export LIVEKIT_API_SECRET=<API Secret hidden>

3. Make an endpoint that returns a token

Create a server that returns a token for a participant to join a room:

require 'livekit'
require 'sinatra'
def createToken
token = LiveKit::AccessToken.new(api_key: 'yourkey', api_secret: 'yoursecret')
token.identity = 'quickstart-identity'
token.name = 'quickstart-name'
token.add_grant(roomJoin: true, room: 'room-name')
token.to_jwt
end
get '/getToken' do
createToken
end

Run the server:

$ source development.env
$ ruby server.rb

4. Create a client app to connect

Create a client app that fetches a token from the server you just made, then uses it to connect to a LiveKit room:

Previous

Chevron IconGo
LiveKit logo

Product

SFU

SDKs

Performance

Deployment