expo-svelte
Svelte 5 components that run as native Android and iOS apps. The components are compiled by a pinned Svelte compiler, run in Hermes, and drive React Native's Fabric shadow tree and Yoga directly. There is no React reconciler, no React Native component layer and no WebView. The build and release pipeline stays Expo: expo prebuild, config plugins, autolinking, Gradle and CocoaPods, EAS Build, EAS Submit and EAS Update.
On Android the mounting is the package's own engine: Fabric's C++ transaction goes to typed Kotlin views instead of React Native's Java mounting. On iOS React Native's mounting is kept and the package adds its own UIKit navigation, sheets, tabs and toolbar. The engine is specified in native/svelte-core/SPEC.md; this file is the way in, REFERENCE.md holds the detail of the JavaScript side, CHANGELOG.md what changed, and PLAN.md what was measured and what is open.
Supported platforms
|
Exercised on |
Notes |
| Android |
Samsung SM-A165F (Android 16, 90 Hz), an API 36 emulator (x86_64) |
arm64 and x86_64 builds; phones only, no tablet or foldable layouts |
| iOS |
iPhone SE 3rd generation (iOS 26.6, 60 Hz) |
phones only; the Android-only engine pieces (view pool, overlay modal, foreign-view split) do not apply |
| Web |
the same app builds for browsers through SvelteKit |
separate target: +page.svelte for browsers, +mobile.svelte for native |
It targets Expo SDK 57 and React Native 0.86.3 with Hermes, Reanimated 4.5.1, react-native-worklets 0.10.1, react-native-gesture-handler 2.32.0 and react-native-svg 15.15.4 (the library carries these four itself: they are not an app's dependencies, "Install in an app"). The Svelte compiler is Svelte's unmerged custom-renderer pull request, pinned to commit 216f258068d93170a927ad4d27ee6864b0b305c5 (5.56.7). The package names it as a peer dependency, svelte 5.56.7 with the ./renderer export, which the registry's 5.56.7 does not have; the repository vendors the build as vendor/svelte-5.56.7-216f258.tgz, and the package and the example app install that tarball by file: (a development dependency here, so a dependent never sees it). The library carries pnpm patches for SvelteKit and expo-modules-core, and for four of the view libraries it wraps (react-native-pdf, react-native-video, react-native-maps, lottie-react-native; patches/); an app that installs the package applies them itself ("Install in an app"). The patches to gesture handler, Reanimated and worklets are already in the copies the library carries. Svelte's compiler is not patched: the custom-renderer build refuses transition:, in:, out: and animate: on native elements, and the Metro transformer removes the two refusals from the compiler's sources as it loads them (module.registerHooks, Node 22.15 or newer; the app's range is 22.17 or newer). Svelte's transition:, in:, out: and animate: play on native elements, on the UI thread ("Animation"); write them on HTML elements (<div in:fly>), which svelte-check accepts: on a component such as <View in:fly> Metro compiles the directive, but svelte-check reports it (a directive on a component). Unsupported: libraries that need the DOM, React widgets, the Expo dev client, Fast Refresh (a save remounts the root; see "Development loop"), tvOS, and tablet layouts (not exercised).
Install in an app
This section and the next two are the reference for what an app needs. To start an app, follow the guide: npx sv create, pnpm add of the library, then pnpm exec expo-svelte init, which does the steps below for you (and init --dry-run prints what it would do). To add the library to an Expo app you already have, see its page.
The package is expo-svelte on npm; a release candidate is on the next tag. examples/minimal is the smallest app that does everything below (copy it to start); scripts/consumer-check.sh installs and builds it from a scratch directory outside the repository, once with the library as a packed tarball and once as a git dependency of the repository's own commit.
pnpm add expo-svelte@next "svelte@https://pkg.pr.new/svelte@216f258068d93170a927ad4d27ee6864b0b305c5"
{
"dependencies": {
"expo-svelte": "0.4.0-rc.10",
"svelte": "https://pkg.pr.new/svelte@216f258068d93170a927ad4d27ee6864b0b305c5"
}
}
A checkout of the repository installs as a pnpm git dependency naming the package's directory, git+ssh://git@github.com/AlfayezDev/svelte-native.git#<ref>&path:packages/expo-svelte or any other repository URL with the same suffix (git+file:///path/to/checkout#<commit>&path:packages/expo-svelte is what the check script installs).
Node. An app runs on Node 24 LTS (24.3 or newer), Node 22.17 or newer, or Node 26 or newer (expo-svelte doctor checks it); not Node 25. React Native 0.86.3 allows Node 25, but asks for @react-native/metro-config by a range, so a fresh install takes 0.88, whose tools exclude it, and pnpm stops with ERR_PNPM_UNSUPPORTED_ENGINE at the first pnpm add (the engineStrict: true that sv create writes), before expo-svelte init can pin the package to React Native's version. The library's Node-side code ships as JavaScript, so an app needs no TypeScript in Node. This repository's own tools (its scripts and tests run TypeScript through Node) need Node 25 or newer, which is the repository's requirement and not an app's.
A machine that reaches the repository only over SSH needs one git setting. pnpm resolves a github.com git dependency over HTTPS whatever the specifier says (git+ssh://git@github.com/… included): pnpm add writes github:AlfayezDev/svelte-native#<tag>&path:packages/expo-svelte to package.json and https://github.com/AlfayezDev/svelte-native.git to the lockfile, so that the lockfile works on every machine. Where git can read the private repository only with an SSH key, pnpm add stops with ERR_PNPM_GIT_RESOLVE_FAILED and a later pnpm install with ERR_PNPM_GIT_FETCH_FAILED (could not read Username for 'https://github.com'). Tell git to use SSH for this account's repositories, once (pnpm's own advice, narrowed to this account):
git config --global url."git@github.com:AlfayezDev/".insteadOf "https://github.com/AlfayezDev/"
A release is a tag with its changelog entry. What pnpm install copies is the package as files packs it (pnpm pack lists it): src/ (TypeScript that Metro compiles), dist/node/ (the JavaScript that Node itself loads, built from src/; see "Set up an app"), dist/types/ (the type declarations an app's type checker reads, built from src/), native/ (the library's native modules), vendor/ (the third-party packages the library carries, with the library's changes already in them), expo-module.config.json, patches/ and the documents. Nothing is built at install time and nothing outside the package directory is needed: pnpm builds nothing for a git dependency, and refuses one whose package.json has a prepare, prepack or prepublish script (ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED, until the app lists it under allowBuilds, and then it installs the package's development dependencies and runs the script in a clone), so dist/node/ and dist/types/ are committed and the package has no such script (a test checks both).
-
Svelte. The renderer needs the custom-renderer build, not the registry's svelte, whose 5.56.7 has the same version string and no ./renderer export. Install it from pkg.pr.new (above), or from the tarball the repository vendors (vendor/svelte-5.56.7-216f258.tgz, byte for byte the same build: pnpm add ./svelte-5.56.7-216f258.tgz, which writes "svelte": "file:./svelte-5.56.7-216f258.tgz"). The package declares svelte as a peer dependency (5.56.7), so a package manager that finds another build warns, and pnpm reports the URL or file: build as an unmet peer (pnpm peers check); that warning is expected. withExpoSvelte (Metro), the Metro transformer and the native target of expoSvelte() (Vite) check the installed package for ./renderer and fail with the same instructions. The web target of SvelteKit runs on the same build.
-
Dependencies of the app. Next to the library and svelte, the app's package.json lists the peers that are not optional, at the versions it was exercised on:
expo 57.0.30 and expo-constants 57.0.22 (the peer ranges are ~57.0.27 and ~57.0.21), react 19.2.7 and react-native 0.86.3;
- Not on this list: the native packages the library carries itself.
crypto on the device (below) is react-native-quick-crypto 1.1.3 and the base64 module it asks for, react-native-quick-base64 2.2.2; localStorage is MMKV (react-native-mmkv 4.3.1) on the Nitro runtime it shares with quick-crypto (react-native-nitro-modules 0.35.10); the Intl constructors Hermes lacks (PluralRules, RelativeTimeFormat, ListFormat, Locale) are hermes-intl 0.1.2; the gestures, the animation and the SVG components of the main entry are react-native-gesture-handler 2.32.0, react-native-reanimated 4.5.1, react-native-worklets 0.10.1 and react-native-svg 15.15.4. All nine are copied into the package (VENDORING.md; the library's patches to gesture handler, Reanimated and worklets are applied to the copies) and the library links them itself, so an app's package.json lists none of them and an app that lists one is refused (the Expo plugin stops the prebuild, expo-svelte doctor and the autolinking fail, with the package's name and what to do: remove it from the dependencies, reinstall, prebuild again). A library of the app that asks for one as a peer dependency is served by the copy: Metro resolves the name to it (and every path below it), the Gradle project and the pod keep the name, and the Worklets Babel plugin is the copy's; the package manager may warn about the missing peer, which is expected. quick-crypto's own JavaScript dependencies (@craftzdog/react-native-buffer, events, readable-stream, safe-buffer, string_decoder, util) are ordinary dependencies of the library, installed with it. libsodium for crypto is the plugin's sodiumEnabled option, which replaces quick-crypto's own Expo plugin (an app no longer lists it);
@sveltejs/kit (3.1.1 exactly) and vite are optional: remote functions and the web target need them (SvelteKit's client runtime is reused, and the Vite plugin runs the web build). An app that builds for native only installs neither, and the Metro plugin, the transformer and the runtime load and bundle without them; a feature that does need SvelteKit fails with a message that names the package.
The view libraries behind the /foreign components (expo-image, react-native-maps, lottie-react-native, ...) are not peers: the package carries them (vendor/, patched where they need it) and an app turns on the ones it uses with libraries in the plugin's options ("Native views from other libraries"). An app that lists one in its package.json is refused.
-
package.json entries. "main": ".expo-svelte/entry.ts", the file expo-svelte sync (and the Metro config) writes; without it Expo falls back to expo/AppEntry.js, which is not the library's entry. Nothing else: Reanimated's flag ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPS, which its package ships off, is on in the library's copy (the patched Android update, the native sink of the engine's animation write path, is reached only through the synchronous update this flag turns on, and the animation numbers in PLAN.md were measured with it), so an app no longer writes { "reanimated": { "staticFeatureFlags": … } }. An app that has one still wins: its value is read over the copy's (ENABLE_SHARED_ELEMENT_TRANSITIONS and this flag cannot both be on, which Reanimated's build checks).
-
pnpm settings. pnpm 12 reads them from the app's pnpm-workspace.yaml (an app that is not a workspace has the file with these keys only):
allowBuilds:
esbuild: true # a dependency of the package; pnpm 12 stops with ERR_PNPM_IGNORED_BUILDS until its install script is allowed
overrides:
expo-modules-core: 57.0.23 # expo asks for ~57.0.23, so a fresh install takes the newest 57.0.x, which the patch below is not for
"@react-native/metro-config": 0.86.3 # react-native asks for it by a range, so a fresh install takes 0.88 beside React Native 0.86.3 (Metro 0.87, tools that exclude Node 25)
Without the first override a fresh install takes 57.0.25 and pnpm stops with ERR_PNPM_UNUSED_PATCH; expo-svelte doctor reports a different version of expo-modules-core with this fix. The second is React Native's version (the one in dependencies): without it the install takes @react-native/metro-config 0.88 and Metro 0.87, whose engines exclude Node 25 (see "Node" above).
The patchedDependencies entries go in the same file ("Apply the patches").
-
Native modules. Nothing is copied into the app. The package's expo-module.config.json links its one native module through Expo's autolinking (the Android Gradle project :svelte-core and the iOS pod SvelteCore, both in native/svelte-core), so expo prebuild and pod install find it in node_modules/expo-svelte/native/. Keep the app's own Expo modules in its modules/ directory as usual.
-
Patches. The patches the library relies on are in the package's patches/ directory; "Apply the patches" below says how an app copies and registers them (patchedDependencies), and pnpm exec expo-svelte doctor checks the result.
-
App config. The Metro, Vite and Expo wiring is the one in "Set up an app" below; run npx expo prebuild after the first install and after a native dependency or a plugin option changes.
-
CI. Declaring the patches changes the lockfile, and with CI=1 pnpm refuses a frozen install of a lockfile that does not match: run pnpm install --no-frozen-lockfile once and commit pnpm-lock.yaml.
Set up an app
examples/minimal is the smallest working app: a root layout, a home screen and a screen pushed on top of it, with the app.json, metro.config.cjs and pnpm-workspace.yaml below. It is its own pnpm workspace and imports nothing from this repository by path. apps/example is the showcase (a screen for each feature) and apps/qa the QA app; both link the library through their workspace dependency, as an app outside the repository does.
// vite.config.ts: browser and native share one config
plugins: [expoSvelte({ target: mode === "native" ? "native" : "web", kit: { /* … */ } })]
// metro.config.cjs
const { getDefaultConfig } = require("expo/metro-config");
const { withExpoSvelte } = require("expo-svelte/metro");
module.exports = withExpoSvelte(getDefaultConfig(__dirname));
// app.json
{ "expo": { "plugins": ["expo-svelte"] } }
// or app.config.ts, with options
plugins: [["expo-svelte", { autolinkingExclude: [], androidOnDemandViewManagers: {} }]]
Name the plugin by the package's own name, as for any Expo library: the package has an app.plugin.js at its root, which Expo looks for before the package's main entry. expo-svelte/app.plugin is that file by its path. (expo-svelte/expo, which named the built file up to 0.4.0-rc.6, was removed in 0.4.0-rc.7 and no longer resolves: write the package's name in its place; expo-svelte init does it in an app.json, and expo-svelte doctor reports it.) No babel.config.js is needed: Expo's default preset gives the same bundle (checked byte for byte). The app needs src/routes/+layout.mobile.svelte (the generated entry imports it as the app shell) and at least one +mobile.svelte.