Skip to content

Installation

  1. Install the packages

    Terminal window
    npx expo install react-native-mediapipe-posedetection react-native-vision-camera react-native-worklets-core
  2. Add the worklets Babel plugin

    Frame processors run as worklets, so babel.config.js needs the worklets plugin:

    babel.config.js
    module.exports = function (api) {
    api.cache(true);
    return {
    presets: ['babel-preset-expo'],
    plugins: [['react-native-worklets-core/plugin']],
    };
    };
  3. Configure the plugins in app.json

    app.json
    {
    "expo": {
    "plugins": [
    [
    "react-native-vision-camera",
    {
    "cameraPermissionText": "$(PRODUCT_NAME) uses the camera to track your body pose."
    }
    ],
    [
    "react-native-mediapipe-posedetection",
    {
    "assetsPaths": ["./assets/models/"]
    }
    ]
    ]
    }
    }

    The second plugin copies every file in assets/models/ into the native projects. See Model files for which model to download.

  4. Build a development client

    This library contains native code, so it won’t run in Expo Go.

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

    Or build with EAS: eas build --profile development.

VisionCamera needs permission before the camera will start:

import { useCameraPermission } from 'react-native-vision-camera';
const { hasPermission, requestPermission } = useCameraPermission();
useEffect(() => {
if (!hasPermission) requestPermission();
}, [hasPermission, requestPermission]);

Next: get a model file.