Skip to main content
This guide will get you started with Ably Chat on a new React Native application. You’ll learn how to create chat rooms, send and edit messages, and implement realtime features like typing indicators and presence.

Prerequisites

Ably

  1. Sign up for an Ably account.
  2. Create a new app, and get your first API key. You can use the root API key that is provided by default, within the API Keys tab to get started.

Create a New Project

  1. Create a new React Native project using the React Native CLI:
  1. Install the Ably Chat SDK and its dependencies:
  1. For iOS, install the native dependencies:

Step 1: Set Up the Ably and Chat Client Providers

The Ably Pub/Sub SDK and the Ably Chat SDK expose React hooks and context providers. The AblyProvider and ChatClientProvider should be used at the top level of your application, typically in App.tsx. In production, you should use token authentication to avoid exposing your API keys publicly. Replace the contents of your App.tsx file with the following code:

Step 2: Connect to Ably

Clients establish a connection with Ably when they instantiate an SDK. Create a new file ChatApp.tsx and add the following functions: In the App.tsx file, add the import and use this component: Run your application: The application should now be running. You should see the connection status displayed with “Connection: connected!”.

Step 3: Create a Room

Now that you have a connection to Ably, you can create a room. The ChatRoomProvider provides access to a specific chat room. Update your ChatApp() component to wrap the contents with a ChatRoomProvider:

Next Steps

Continue to explore the documentation with React Native as the selected language: Explore the Ably CLI further, or check out the Chat JS API references for additional functionality.

Build docs developers (and LLMs) love