Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions content/docs/expo/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ description: "Release notes for the Superwall Expo SDK"

# Changelog

## 1.1.3

### Patch Changes

- a8ba5af: Add localResources resolving for expo

## 1.1.2

### Patch Changes
Expand Down
4 changes: 4 additions & 0 deletions content/docs/expo/guides/configuring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Expo apps inherit the native Superwall option surface. The following fields were
description: "Controls when the SDK enters test mode. When active, purchases are simulated and product data is retrieved from the Superwall dashboard. Set to \"always\" during development to test your entire paywall flow without StoreKit or Play Store.",
default: '"automatic"',
},
localResources: {
type: "Record<string, LocalResource>",
description: "A mapping of local resource IDs to local assets. The paywall webview can reference these via the `swlocal://<id>` URL scheme. Accepts a Metro `require()` result, a file URI string, or a `{ uri: string }` object. Resolved at configure time.",
},
}}
/>

Expand Down
6 changes: 6 additions & 0 deletions content/docs/expo/guides/local-resources.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "Local Resources"
description: "Bundle images, videos, and other assets in your app so paywalls can load them instantly from the device."
---

<include>../../../shared/local-resources.mdx</include>
2 changes: 1 addition & 1 deletion content/docs/expo/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues please [open an issue on GitHub](https://github.com/superwall/expo-superwall/issues).

<SdkLatestVersion version="v1.1.2" repoUrl="https://github.com/superwall/expo-superwall" />
<SdkLatestVersion version="v1.1.3" repoUrl="https://github.com/superwall/expo-superwall" />
1 change: 1 addition & 0 deletions content/docs/expo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"guides/managing-users",
"guides/experimental-flags",
"guides/testing-purchases",
"guides/local-resources",
"guides/setting-locale",
"guides/advanced",
"guides/migrations",
Expand Down
2 changes: 1 addition & 1 deletion content/docs/expo/sdk-reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ If you have feedback on any of our docs, please leave a rating and message at th

If you have any issues with the SDK, please [open an issue on GitHub](https://github.com/superwall/expo-superwall/issues).

<SdkLatestVersion version="v1.1.2" repoUrl="https://github.com/superwall/expo-superwall" />
<SdkLatestVersion version="v1.1.3" repoUrl="https://github.com/superwall/expo-superwall" />
54 changes: 54 additions & 0 deletions content/shared/local-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Local resources let your paywalls load bundled assets directly from the device i
</Info>
:::

:::expo
<Info>
Local resources require **Expo SDK v1.1.3+**.
</Info>
:::

## Registering local resources

Choose a stable resource ID for each asset you want to serve locally. That same ID is what you'll select in the [paywall editor](/dashboard/dashboard-creating-paywalls/paywall-editor-local-resources) when configuring image or video components.
Expand Down Expand Up @@ -80,6 +86,37 @@ class MyApplication : Application() {
</Warning>
:::

:::expo
On Expo, pass `localResources` in the `options` prop on `SuperwallProvider`. Entries are resolved during configuration — Metro `require()` results are downloaded via `expo-asset` so the webview can read them from a `file://` URI.

```tsx Expo
import * as FileSystem from "expo-file-system"
import { SuperwallProvider } from "expo-superwall"

export function App() {
return (
<SuperwallProvider
apiKeys={{ ios: "pk_your_ios_api_key", android: "pk_your_android_api_key" }}
options={{
localResources: {
"hero-image": require("./assets/hero.png"),
"logo": { uri: FileSystem.documentDirectory + "logo.png" },
"onboarding-video": "file:///path/to/welcome.mp4",
},
}}
>
{/* your app */}
</SuperwallProvider>
)
}
```

<Warning>
`localResources` is resolved when `SuperwallProvider` configures the SDK. Resources added later
will not be available to paywalls that already loaded.
</Warning>
:::

## Supported source types

:::ios
Expand All @@ -99,6 +136,16 @@ Android supports two local resource source types:
| `PaywallResource.FromUri(uri)` | Files addressed by a `Uri`, such as files in app storage or content provider URLs |
:::

:::expo
Each entry in `localResources` accepts one of:

| Type | Use for |
| ---- | ------- |
| `number` (Metro `require()`) | Bundled assets in your Expo project; resolved through `expo-asset` |
| `string` | A `file://`, `content://`, or absolute path URI |
| `{ uri: string }` | The same shape used by React Native `Image` sources |
:::

## Choosing resource IDs

Resource IDs are the contract between your app and the paywall editor. A few guidelines:
Expand Down Expand Up @@ -130,6 +177,13 @@ If a resource ID does not appear in the editor or fails to load:

## Related

:::ios
- [iOS `localResources`](/sdk/sdk-reference/localResources): SDK reference for the iOS property.
:::
:::android
- [Android `localResources`](/sdk/sdk-reference/localResources): SDK reference for the Android property.
:::
:::expo
- [Configuring the SDK](/expo/guides/configuring): Where `localResources` lives in the Expo options surface.
:::
- [Paywall Editor: Local Resources](/dashboard/dashboard-creating-paywalls/paywall-editor-local-resources): How to assign local resource IDs in the dashboard.
Loading