Skip to Content
Rampart

Getting started

Planned installation and first use in an Expo app.

Planned API. Not yet published to npm.

Install

npx expo install expo-rampart

Add the config plugin to app.json (see Config plugin for every option):

app.json
{
  "expo": {
    "plugins": [
      [
        "expo-rampart",
        {
          "android": { "expectedSigningCertSha256": ["AB:CD:EF:…"] },
          "ios": { "expectedTeamId": "ABCDE12345" }
        }
      ]
    ]
  }
}

Rampart is a native module, so it needs a development build (it does not run in Expo Go). Rebuild after adding it:

npx expo prebuild --clean
npx expo run:android   # or run:ios

Listen for threats

app/_layout.tsx
import { useEffect } from 'react';
import Rampart from 'expo-rampart';

export default function RootLayout() {
  useEffect(() => {
    Rampart.configure({ intervalMs: 60_000 });
    const sub = Rampart.addThreatListener((event) => {
      // event.id, event.confidence, event.evidence
      reportRiskToMyBackend(event); // your code, your server
    });
    return () => sub.remove();
  }, []);
  // …
}

Or read the current state in a component:

import { useThreats } from 'expo-rampart';

function PayButton() {
  const threats = useThreats();
  const risky = threats.some((t) => t.confidence === 'high');
  return <Button disabled={risky} title="Pay" onPress={pay} />;
}

Protect a sensitive screen

import { SecureView } from 'expo-rampart';

<SecureView>
  <HealthFormAnswers />
</SecureView>;

On this page