RelayBox CLI
The RelayBox CLI offers a set of tools to help you easily build and test your application locally. With just a few simple commands, you can quickly start up the necessary services and connect your apps within seconds.
Behind the scenes, Docker containers are orchestrated to efficiently manage your local service stack.
Installing the RelayBox CLI
To begin working offline, simply install the cli via npm.
npm install -g relaybox
Once the installation is complete, you'll have access to tools which will assist with setting up an application.
Starting the platform
Once the CLI is installed, go ahead and start the platform.
> relaybox platform up
If everything is installed as expected, you'll see container images being pulled from the RelayBox DockerHub repositories.
After the download process is complete, the process will continue bootstrapping the platform and starting up the various services.
Creating an application
Think of an application as a workspace that provides live authentication services, key-based security, usage metrics, user presence tracking, and much more.
We'll explore these concepts in more detail soon, but for now, let's create an application. Simply run the following command in your terminal.
> relaybox application create
When prompted, choose an application name. Don't worry, this can be changed later if required.
> Choose an application name:
Your application will be created and you'll be provided with some access keys. Make a note of the apiKey and publicKey. We'll need them for the next steps as we begin to connect an application.
{
id: 'gyyeqecxuhuz',
publicKey: 'gyyeqecxuhuz.wotylbxdurq5',
apiKey: 'gyyeqecxuhuz.wotylbxdurq5:b9d1d981b50991964461b92722b6c50c712a4295a67068e948b475082b4ddcd2'
}
Think of the publicKey as a unique indentifier for your application. It will be required for access to realtime and live auth services.
Important: Avoid exposing your apiKey in client side applications. An apiKey contains a generated secret key used to sign authentication tokens and push based messages.
Connecting an application
Now that you've created an application and have your apiKey and publicKey, you're ready to connect your application to the offline platform emulator.
If you haven't done so already, be sure to install the client library SDK to get started.
npm install @relaybox/client
The client library SDK provides the tools necessary to connect to RelayBox services, whether thats via RelayBox Cloud or the offline platform emulator.
For the full api reference, please refer to the developer docs.
To continue, let's connect your application by adding the following code.
import RelayBox from '@relaybox/client';
const relayBox = new RelayBox({
publicKey: 'gyyeqecxuhuz.wotylbxdurq5',
offline: {
enabled: true
}
});
relayBox.connect();
Congratulations! You've initialized an application and can now begin to interact with the realtime services using the RelayBox Client Library SDK.
For a complete api reference, please refer to the @relaybox/client developer docs.