Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@medplum/expo-polyfills
Advanced tools
A module for polyfilling the minimum necessary web APIs for using the Medplum client on React Native
A module for polyfilling the minimum necessary web APIs for using the Medplum client on React Native
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
npm install @medplum/expo-polyfills
There are currently two major components to this package:
MedplumClient
working without errors in React Native
. See: [polyfillMedplumWebAPIs
]ExpoClientStorage
class, which enables MedplumClient
to persist what is normally stored in LocalStorage
on the web client into a secure storage on a mobile device. Under the hood it uses Expo's SecureStore
, but abstracts away the complexity of its asynchronous APIs, since the Storage
interface is normally synchronous in nature.To get full compatibility with the MedplumClient
in React Native, call the polyfillMedplumWebAPIs
in the app root and pass in an ExpoClientStorage
into your MedplumClient
.
If you want to wait to load components until after the MedplumClient
has initialized, you can conditionally render based on the loading
property from the useMedplumContext
hook.
import { MedplumClient } from '@medplum/core';
import { MedplumProvider, useMedplumContext } from '@medplum/react-hooks';
import { polyfillMedplumWebAPIs, ExpoClientStorage } from '@medplum/expo-polyfills';
polyfillMedplumWebAPIs();
const medplum = new MedplumClient({ storage: new ExpoClientStorage() });
function Home(): JSX.Element {
const { loading } = useMedplumContext();
return loading ? <div>Loading...</div> : <div>Loaded!</div>;
}
function App(): JSX.Element {
return (
<MedplumProvider medplum={medplum}>
<Home />
</MedplumProvider>
);
}
Expo Router
When using MedplumClient
with Expo Router
, you will likely need to disable the polyfill for window.location
; Expo Router
provides a polyfill that better interoperates with the package than the Medplum-provided one. See: https://expo.github.io/router/docs/lab/runtime-location#native
To disable the Medplum window.location
polyfill, simply pass the following config to polyfillMedplumWebAPIs
:
polyfillMedplumWebAPIs({ location: false });
FAQs
A module for polyfilling the minimum necessary web APIs for using the Medplum client on React Native
The npm package @medplum/expo-polyfills receives a total of 294 weekly downloads. As such, @medplum/expo-polyfills popularity was classified as not popular.
We found that @medplum/expo-polyfills demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.