Skip to content

Commit 76ec2e1

Browse files
committed
docs: add a warning on getting started page, fix the link in resource fetcher error message
1 parent 48610bf commit 76ec2e1

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

docs/docs/01-fundamentals/01-getting-started.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,59 @@ For supported React Native and Expo versions, see the [Compatibility table](../0
3838

3939
## Installation
4040

41-
Installation is pretty straightforward, just use your favorite package manager.
41+
Installation is pretty straightforward, use your package manager of choice to install the package and some peer dependencies required to streamline model downloads. If you want to implement your custom model fetching logic, see [this document]().
4242

4343
<Tabs>
4444
<TabItem value="npm" label="NPM">
4545

4646
```
4747
npm install react-native-executorch
48+
# For Expo projects
49+
pnpm install react-native-executorch-expo-resource-fetcher
50+
# For bare RN projects
51+
npm install react-native-executorch-bare-resource-fetcher
4852
```
4953

5054
</TabItem>
5155
<TabItem value="pnpm" label="PNPM">
5256

5357
```
5458
pnpm install react-native-executorch
59+
# For Expo projects
60+
pnpm install react-native-executorch-expo-resource-fetcher
61+
# For bare RN projects
62+
pnpm install react-native-executorch-bare-resource-fetcher
63+
5564
```
5665

5766
</TabItem>
5867
<TabItem value="yarn" label="YARN">
5968

6069
```
6170
yarn add react-native-executorch
71+
# For Expo projects
72+
yarn install react-native-executorch-expo-resource-fetcher
73+
# For bare RN projects
74+
yarn install react-native-executorch-bare-resource-fetcher
6275
```
6376

6477
</TabItem>
6578
</Tabs>
6679

80+
:::warning
81+
Before using any other API, you must call `initExecutorch` with a resource fetcher adapter at the entry point of your app:
82+
83+
```js
84+
import { initExecutorch } from 'react-native-executorch';
85+
import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher';
86+
// or ExpoResourceFetcher for Expo projects
87+
88+
initExecutorch({ resourceFetcher: BareResourceFetcher });
89+
```
90+
91+
Calling any library API without initializing first will throw a `ResourceFetcherAdapterNotInitialized` error.
92+
:::
93+
6794
Our library offers support for both bare React Native and Expo projects. Please follow the instructions from [Loading models section](./02-loading-models.md) to make sure you setup your project correctly. We encourage you to use Expo project if possible. If you are planning to migrate from bare React Native to Expo project, the link (https://docs.expo.dev/bare/installing-expo-modules/) offers a guidance on setting up Expo Modules in a bare React Native environment.
6895

6996
If you plan on using your models via require() instead of fetching them from a url, you also need to add following lines to your `metro.config.js`:

packages/react-native-executorch/src/utils/ResourceFetcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class ResourceFetcher {
106106
static getAdapter(): ResourceFetcherAdapter {
107107
if (!this.adapter) {
108108
const errorMessage =
109-
'ResourceFetcher adapter is not initialized. Please call initExecutorch({ resourceFetcher: ... }) with a valid adapter, e.g., from react-native-executorch-expo-resource-fetcher or react-native-executorch-bare-resource-fetcher. For more details please refer: https://docs.swmansion.com/react-native-executorch/docs/next/fundamentals/loading-models';
109+
'ResourceFetcher adapter is not initialized. Please call initExecutorch({ resourceFetcher: ... }) with a valid adapter, e.g., from react-native-executorch-expo-resource-fetcher or react-native-executorch-bare-resource-fetcher. For more details please refer to: https://docs.swmansion.com/react-native-executorch/docs/next/fundamentals/loading-models';
110110
// for sanity :)
111111
Logger.error(errorMessage);
112112
throw new RnExecutorchError(

0 commit comments

Comments
 (0)