Packages

Import NPM packages into your app

You can add compatible NPM packages to your app project to extend functionality and features.

⚠️

React Native & Expo

Imported libraries must be compatible with React Native and the Expo managed workflow

⚠️

Cocoapods

Packages which require running pod install for iOS installation are not currently supported. Look for packages without this requirement

⚠️

Linking

Packages which require linking are not currently supported. Look for packages which have auto-linking

Finding compatible packages

A great place to start is Expo's packages since Draftbit apps are built using the Expo toolset for React Native. In fact, there's already several of these built-in that you can enable in your Functions.

You can find several compatible libraries in the React Native directory as well. Make sure they also meet the above requirements.

If you want to import libraries from the npm registry, please follow Expo's tips for determining compatibility.

Adding a package

First, navigate to the Packages tab in the Custom Code modal.

Click the "+" icon to add a new package.

Then, enter your Package Name in the first input field and it's Version in the second input field.

❗️

Avoid using the latest version of a package.

Since using the latest version of a package can cause your app to break unexpectedly when Draftbit or the package is updated, avoid using latest as the version. Instead enter a specific version number (e.g. 3.33)with or without npm ~, ^, or >= syntax.

Check below for a list of common packages and their compatible version.

To remove a package, click the '-' button at the end of the row where the package is listed.

Using an Imported Package

As an example of how you might use an imported package in your app, we'll demonstrate importing a package that lets us encode some text into a base64 string.

Import the package

Add the following package to your app imports

react-native-quick-base64

You can read more about this package here: https://github.com/craftzdog/react-native-quick-base64

Save and close

Export the needed modules

Since we want to use the package's functionality in a Custom Function we'll export the modules we need from a Custom File. Let's name the file Base64 and in our case we want to expose the methods for encoding and decoding.

export { btoa, atob } from 'react-native-quick-base64';

Save and close

📘

For info on using a package for JSX components, see the JSX docs.

Use the modules in a Custom Function

Now that we've made our encode/decode logic available in a Custom File, we can import that package into a Custom Function and use it. Let's create a new Global Function and name it base64Encode

We'll create a new Parameter which will be the value we pass to this function that we want to encode, and we'll add the file we created previously in the Custom File Imports section which will add the import above the function.

Since the name of our Custom File is Base64that is the name used when importing the file. So we can then access our exported methods from the file.

return Base64.btoa(value)

Base64 being the name of our import and btoa being one of the exported modules in the file.

Save and close

Use the Custom Function in your app

We are now able to use our Custom Function to encode a text to base64. We can use them in a Transform Function or in an Action flow, for example.

Here it's being used as a transform in a Text component

📘

If you need to expose modules from a package to Custom Functions, then you can export them from a Custom File which can then be used from a Custom Function. For instance, you can have a single Libsfile for all your exports.

If you are using a package that provides a JSX component, for instance, then you can instead import the package at the top of your Custom File and then export a component for use with a Custom Code component.

Expo SDK Packages

The following are common packages in the Expo SDK that are not yet part of the Draftbit platform. We've made these available by default for use in Custom Functions.

Examples for how to add these to your Draftbit app in custom code are here.

Package NameDescription
expo-assetPackage that provides an interface to access Expo's asset system.
expo-avPackage that provides Audio.Sound objects and Video components for managing audio and video playback.
expo-clipboardProvides an interface for getting and setting Clipboard content on Android, and iOS.
expo-constantsProvides system information that remains constant throughout the lifetime of an app's install.
expo-cameraProvides a component to use the device's camera to take photos or record video.

*Must require CAMERA permissions for the camera and AUDIO_RECORDING permissions to record video.
expo-barcode-scannerProvides a component to use the device's camera as a barcode scanner.

*Must require CAMERA permissions
expo-permissionsPackage that handles asking the user for various device permissions.
expo-image-pickerPackage that provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera.

*Must require CAMERA permissions for the camera and MEDIA_LIBRARY permissions to access and select from phone's library.
expo-sensorsProvides various APIs for accessing device sensors to measure motion, orientation, pressure, magnetic fields, and step count.
expo-sharingPackage that allows sharing files directly with other compatible applications.
expo-smsPackage that provides access to the system's UI/app for sending SMS messages.
Async StorageProvides an asynchronous, unencrypted, persistent, key-value storage solution
RN AlertLaunches an alert dialog with the specified title and message.
RN AppearancePackage that exposes information about the user's appearance preferences, such as their preferred color scheme (light or dark).
RN DimensionsPackage that updates width and height values when screen size changes.
RN KeyboardPackage that provides methods to control keyboard events.
RN PlatformPackage that provides a module to detect the platform (iOS or Android) in which the app is running. Platform specific tasks are handled using it.
RN VibrationPackage that contains the method to trigger a vibration with a fixed duration. The duration here is specified in milliseconds.

Recommended Package Versions

Some packages have specific versions which should be used. Below you'll find a list of some of those packages and the recommended version to use.

PackageVersion
@shopify/mime-types2.0.0
react-native-purchases^5.0.1
stream-chat-expo^5.1.0
victory-native^36.6.7
package47484950
@draftbit/core^47.0.0^48.0.0^49.0.0^50.0.0
@draftbit/maps^47.0.0^48.0.0^49.0.0^50.0.0
@draftbit/native^47.0.0^48.0.0^49.0.0^50.0.0
@draftbit/types^47.0.0^48.0.0^49.0.0^50.0.0
@draftbit/ui^47.0.0^48.0.0^49.0.0^50.0.0
@draftbit/themes---^50.0.0
@draftbit/web-maps^47.0.0^48.0.0deprecateddeprecated
@expo/vector-icons^13.0.0^13.0.0^13.0.0^14.0.0
@react-native-async-storage/async-storage~1.17.31.17.111.18.21.21.0
@react-native-community/datetimepicker6.3.56.7.37.2.07.6.1
@react-native-community/netinfo9.3.59.3.79.3.1011.1.0
@react-native-community/slider4.2.44.4.24.4.24.4.2
@react-native-masked-view/masked-view0.2.80.2.80.2.90.3.0
@react-native-picker/picker2.4.82.4.82.4.102.6.1
@react-native-segmented-control/segmented-control2.4.02.4.02.4.12.4.1
@segment/analytics-react-native2.10.02.13.22.13.22.19.1
@segment/sovran-react-native0.4.5^0.4.5^0.4.5^1.1.1
@sentry/react-native4.9.04.15.25.5.0~5.20.0
@shopify/flash-list1.3.11.4.01.4.31.6.3
@shopify/react-native-skia0.1.1570.1.1720.1.1960.1.221
@stripe/stripe-react-native0.19.00.23.30.28.0~0.35.1
expo-analytics-amplitude~11.3.0~11.3.0~11.3.0~11.3.0
expo-app-auth~11.1.0~11.1.0deprecateddeprecated
expo-app-loader-provider~8.0.0~8.0.0deprecateddeprecated
expo-app-loading~2.1.1deprecateddeprecateddeprecated
expo-apple-authentication~5.0.1~6.0.1~6.1.0~6.3.0
expo-application~5.0.1~5.1.1~5.3.0~5.8.4
expo-asset~8.7.0~8.9.1~8.10.1~9.0.2
expo-auth-session~3.8.0~4.0.3~5.0.2~5.4.0
expo-av~13.0.3~13.2.1~13.4.1~13.10.6
expo-background-fetch~11.0.111.1.111.3.0~11.8.1
expo-barcode-scanner~12.1.0~12.3.2~12.5.3~12.9.3
expo-battery~7.0.0~7.1.1~7.3.0~7.7.2
expo-blur~12.0.1~12.2.2~12.4.1~12.9.2
expo-brightness~11.0.1~11.2.1~11.4.1~11.8.0
expo-build-properties~0.4.1~0.6.0~0.8.3~0.11.1
expo-calendar~11.0.1~11.1.1~11.3.2~12.2.1
expo-camera~13.1.0~13.2.1~13.4.4~14.1.3
expo-cellular~5.0.1~5.1.1~5.3.0~5.7.1
expo-checkbox~2.2.2~2.3.1~2.4.0~2.7.0
expo-clipboard~4.0.1~4.1.2~4.3.1~5.0.1
expo-constants~14.0.2~14.2.1~14.4.2~15.4.6
expo-contacts~11.0.1~12.0.1~12.2.0~12.8.2
expo-crypto~12.0.0~12.2.1~12.4.1~12.8.1
expo-dev-client~2.0.1~2.2.1~2.4.11~3.3.11
expo-device~5.0.0~5.2.1~5.4.0~5.9.4
expo-document-picker~11.0.1~11.2.2~11.5.4~11.10.1
expo-error-recovery~4.0.1deprecateddeprecateddeprecated
expo-face-detector~12.0.0~12.1.1~12.2.0~12.6.1
expo-file-system~15.1.1~15.2.2~15.4.4~16.0.9
expo-firebase-analytics~8.0.0deprecateddeprecateddeprecated
expo-firebase-core~6.0.0deprecateddeprecateddeprecated
expo-firebase-recaptcha~2.3.1deprecateddeprecateddeprecated
expo-font~11.0.1~11.1.1~11.4.0~11.10.3
expo-gl-cpp~11.4.0~11.4.0~11.4.0~11.4.0
expo-gl~12.0.1~12.4.0~13.0.1~13.6.0
expo-google-app-auth~8.3.0deprecateddeprecateddeprecated
expo-haptics~12.0.1~12.2.1~12.4.0~12.8.1
expo-image-loader~4.0.0~4.1.1~4.3.0~4.6.0
expo-image-manipulator~11.0.0~11.1.1~11.3.0~11.8.0
expo-image-picker~14.0.2~14.1.1~14.3.2~14.7.1
expo-in-app-purchases~14.0.0~14.1.1~14.3.0~14.3.0
expo-intent-launcher~10.3.1~10.5.2~10.7.0~10.11.0
expo-keep-awake~11.0.1~12.0.1~12.3.0~12.8.2
expo-linear-gradient~12.0.1~12.1.2~12.3.0~12.7.2
expo-linking~3.3.1~4.0.1~5.0.2~6.2.2
expo-local-authentication~13.0.2~13.3.0~13.4.1~13.8.0
expo-localization~14.0.0~14.1.1~14.3.0~14.8.4
expo-location~15.0.1~15.1.1~16.1.0~16.5.5
expo-mail-composer~12.0.0~12.1.1~12.3.0~12.7.1
expo-media-library~15.0.0~15.2.3~15.4.1~15.9.2
expo-module-template~10.8.3~10.7.17~10.9.6~10.13.2
expo-modules-core~1.1.1~1.2.7~1.5.10~1.11.13
expo-navigation-bar~2.0.1~2.1.1~2.3.0~2.8.1
expo-network~5.0.0~5.2.1~5.4.0~5.8.0
expo-notifications~0.17.0~0.18.1~0.20.1~0.27.7
expo-permissions~14.0.0~14.1.1~14.2.1~14.4.0
expo-print~12.0.0~12.2.1~12.4.2~12.8.1
expo-random~13.0.0~13.1.1~13.2.0~13.6.0
expo-screen-capture~5.0.0~5.1.1~5.3.0~5.8.1
expo-screen-orientation~5.0.1~5.1.1~6.0.6~6.4.1
expo-secure-store~12.0.0~12.1.1~12.3.1~12.8.1
expo-sensors~12.0.1~12.1.1~12.3.0~12.9.1
expo-sharing~11.0.1~11.2.2~11.5.0~11.10.0
expo-sms~11.0.0~11.2.1~11.4.0~11.7.1
expo-speech~11.0.0~11.1.1~11.3.0~11.7.0
expo-splash-screen~0.17.5~0.18.2~0.20.5~0.26.4
expo-sqlite~11.0.0~11.1.1~11.3.3~13.4.0
expo-status-bar~1.4.2~1.4.4~1.6.0~1.11.1
expo-store-review~6.0.0~6.2.1~6.4.0~6.8.3
expo-system-ui~2.0.1~2.2.1~2.4.0~2.9.4
expo-task-manager~11.0.1~11.1.1~11.3.0~11.7.3
expo-tracking-transparency~3.0.1~3.0.3~3.1.0~3.3.0
expo-updates~0.15.6~0.16.4~0.18.17~0.24.12
expo-video-thumbnails~7.0.0~7.2.1~7.4.0~7.9.0
expo-web-browser~12.0.0~12.1.1~12.3.2~12.8.2
lottie-react-native5.1.45.1.45.1.66.5.1
react-dom18.1.018.2.018.2.018.2.0
react-native-branch^5.4.0^5.4.0^5.4.0^5.4.0
react-native-gesture-handler~2.8.0~2.9.0~2.12.0~2.14.0
react-native-get-random-values~1.8.0~1.9.0~1.9.0~1.8.0
react-native-maps1.3.21.3.21.7.11.10.0
react-native-pager-view6.0.16.1.26.2.06.2.3
react-native-reanimated~2.12.0~2.14.4~3.3.0~3.6.2
react-native-safe-area-context4.4.14.5.04.6.34.8.2
react-native-screens~3.18.0~3.20.1~3.22.0~3.29.0
react-native-svg13.4.013.4.013.9.014.1.0
react-native-view-shot3.4.03.5.03.7.03.8.0
react-native-web~0.18.9~0.8.10~0.19.6~0.19.6
react-native-webview11.23.111.26.013.2.213.6.4
react-native0.70.50.71.80.72.60.73.6
react18.1.018.2.018.2.018.2.0
sentry-expo~6.0.0~6.2.0~7.0.0~7.2.0
unimodules-app-loader~4.0.0~4.1.1~4.2.0~4.5.1
unimodules-image-loader-interface~6.1.0~6.1.0~6.1.0~6.1.0

What’s Next

Learn about using imported packages in your app