ScaleBun
Skip to article

React Native quick start

react-nativeDeveloper

Install the React Native SDK, initialise it, and confirm your first session reaches the dashboard.

Updated Reviewed

This takes about five minutes and ends with a session visible in the dashboard.

1. Install the package#

Terminal
npm install @scalebun/react-nativecd ios && pod install

2. Then follow these steps#

  1. Create an app and get credentials

    In the dashboard, create an Organization → Project → App. Each app has environments (development, staging, production), and each environment issues its own key pair under Workspace → SDK & API keys.

    You need three values for the SDK, all shown in the app's SDK setup panel: the project ID, the publishable key, and the API base URL. Read the base URL from the panel rather than hard-coding a host — it differs per deployment.

  2. Initialise once, as early as possible

    App.tsxTypeScript
    import ScaleBun from '@scalebun/react-native';
    await ScaleBun.init({  projectId: '<YOUR_PROJECT_ID>',  publishableKey: '<YOUR_PUBLISHABLE_KEY>',  apiBaseUrl: '<YOUR_API_BASE_URL>',});

    init() is safe to call concurrently — a second call before the first resolves reuses the in-flight bootstrap rather than running a second one. Every capability is on by default; see Configuration to opt out.

  3. Enable automatic screen detection

    This is the recommended way to get screen names into sessions, replays and performance traces. Pass your navigation container ref once and the SDK feeds every subsystem — no per-screen wrapper needed.

    App.tsxTypeScript
    import { NavigationContainer } from '@react-navigation/native';import ScaleBun from '@scalebun/react-native';
    const navigationRef = React.createRef();
    export default function App() {  React.useEffect(() => {    ScaleBun.setNavigationRef(navigationRef);  }, []);
      return <NavigationContainer ref={navigationRef}>{/* screens */}</NavigationContainer>;}
  4. Identify the user once you know who they are

    TypeScript
    ScaleBun.identify('user_123', { plan: 'pro', email: 'ada@example.com' });

    Call this after sign-in. Before it, activity is attributed to the device. See Identity.

  5. Verify

    Trigger an error, then check Diagnose → Errors in the dashboard. Data typically appears within about a minute.

    TypeScript
    ScaleBun.captureError(new Error('ScaleBun test error'), { where: 'quick-start' });

Confirm it worked#

You should see all of the following:

  • A session in Monitor → All sessions.

  • Your test error in Diagnose → Errors.

  • Your screen names on the session timeline.

If none of that appears, work through SDK troubleshooting — the first checks there (credentials, base URL, network) resolve most cases.

Next steps#