Repository navigation
Releases
@alfayez/svelte-native 0.4.0-rc.9
Added
- The optional native view libraries are vendored and turned on in the config plugin's new
librariesoption, one by one:expo-image57.0.5,expo-blur57.0.3,expo-linear-gradient57.0.2,expo-conic-gradient0.2.1,expo-video57.0.5,react-native-video6.19.3,lottie-react-native7.3.8,rive-react-native9.7.1,@react-native-community/datetimepicker9.1.0,react-native-pdf7.0.3 (withreact-native-blob-util0.24.9, which it turns on),react-native-webview13.16.1,react-native-maps1.27.2,react-native-view-shot5.1.0,react-native-fast-shadow0.1.1 andreact-native-animateable-text0.19.3 (VENDORING.md, "Optional libraries"). A library istrueor the options of its own config plugin ("react-native-maps": { androidGoogleMapsApiKey }), which the plugin runs from the copy. A listed library is linked on Android and iOS and bundled by Metro; an unlisted one is none of that: no native code in the build (on iOS not even compiled, so an app without react-native-maps has no CoreLocation reference for App Store Connect to ask a purpose string for), Metro resolves its name to a stub that says how to turn it on, and its components throw the same. React Native's libraries are--linkarguments ofandroid-autolinkingandios-autolinking(an original that autolinking finds of a library that is off is taken out), Expo's modules are search paths of Expo's own autolinker (expoAutolinking.searchPathsafter a--, because Expo's command reads the paths after its--excludeoptions as names to exclude, anduse_expo_modules!(searchPaths:)), and the Metro stubs and the manifest'sextra.svelteNative.librariescome from the same option.svelte-native doctorlists the libraries that are on and refuses an app that lists one in itspackage.json(or its plugin inplugins). createVideoPlayerfrom@alfayez/svelte-native/foreign:expo-video's own function, typed from the copy, for theplayerofVideoView(the package is not installed, soexpo-video/build/VideoPlayercannot be imported where a type checker looks).- Push notifications, straight from the app's server to Firebase Cloud Messaging (Android) and the Apple Push Notification service (iOS) with the app's own credentials: no relay and no push service of Expo's (PUSH.md, and the guide's "Push notifications" page, which also sets up React Native Firebase and
expo-notificationsfor apps that want those). Push is part of the library, with nothing to install: the config plugin'scapabilities.pushturns it on for the platforms it names (the Google services file, the notification icon, color and channel, theaps-environmententitlement and theremote-notificationbackground mode), and only then does Firebase Messaging (26.0.2, Android) join the app's build; iOS goes to APNs without the Firebase SDK. An app with push off has none of Firebase and bundles none of push's JavaScript. The plugin refuses a server secret in the app (a service account key, a private key, a.p8), and refusesexpo-notificationsor@react-native-firebase/messagingbeside it: an app has one push library. pushfrom@alfayez/svelte-native/push:permission(reactive),subscribe({ save }), which asks for the permission, registers with the provider and callssavewhen the token is new or rotated,unsubscribe()andon("message"); and thepushhooks ofsrc/hooks.mobile.ts:foreground(how a message shows while the app is open),background(a data message, with no screen mounted: a process the system starts for one runs the hooks and shows its first screen only when the user opens the app, on iOS too) andopened. A tapped notification is a link: itsurl(a path of the app or a full link) opens through the router as any link does, from a cold start or with the app running, andopenedreturningfalsestops it.createPushfrom@alfayez/svelte-native/push/server, the sender for Node:send(token, message)to FCM's HTTP v1 API (an OAuth token from the service account key, cached) or to APNs over HTTP/2 (an ES256 token from the.p8, the sandbox or production host by the token's environment), with a result whosereasonsays what to do (gone: delete the token;rate-limitedandunavailable: retry later; the others: a bug), andclose(). Node'scryptoandhttp2only. The queue, the retries, the tokens' storage and fan-out are the app's, and the guide says how.- The command line for push:
svelte-native doctorhas a push section (the package and its version, a second push library, the Google services file and its package, the iOS entitlement and background mode after a prebuild);svelte-native doctor --serverchecks a server'sFCM_SERVICE_ACCOUNTandAPNS_KEY,APNS_KEY_IDandAPNS_TEAM_IDand asks each provider once whether it accepts them; andsvelte-native push sendsends one message to one token with them. No line prints a key or a token.
Changed
- The view libraries (
expo-image,expo-blur,expo-linear-gradient,expo-conic-gradient,expo-video,react-native-video,lottie-react-native,rive-react-native,@react-native-community/datetimepicker,react-native-pdf,react-native-blob-util,react-native-webview,react-native-maps,react-native-view-shot,react-native-fast-shadow,react-native-animateable-text) are no longer optional peers. Remove them from the app'spackage.json(the prebuild and the doctor refuse an app that lists one) and list the ones it uses underlibrariesin the plugin's options; the options of their own plugins (["react-native-maps", { androidGoogleMapsApiKey }]inplugins) move there too. The pnpm patches oflottie-react-native,react-native-maps,react-native-pdfandreact-native-videoare in the copies now (vendor-patches/): remove theirpatchedDependenciesentries andpatches/svelte-native/files;svelte-native initno longer copies them. react-native-pdf's copy also finds react-native from the app's directory, since it is no longer beside it innode_modules. - The library carries its third-party native dependencies itself, starting with
react-native-nitro-modules0.35.10 andreact-native-mmkv4.3.1 (VENDORING.md): their published source is copied intovendor/of the package, so an app'spackage.jsonlists the library and not them. Neither is a peer dependency any more,svelte-native initdoes not install them, and an app that still lists either is refused: the Expo plugin stops the prebuild,svelte-native doctorfails, and the autolinking commands refuse it at build time (the library links its copy, and the app's own would be linked beside it). Remove both from the app's dependencies, install again and prebuild again: the Android and iOS builds link the copies from the library's directory (svelte-native android-autolinkingand the newsvelte-native ios-autolinking, which the plugin writes intosettings.gradleand the Podfile), and Metro resolves the namesreact-native-mmkvandreact-native-nitro-modulesto the same copies for every importer, react-native-quick-crypto included. The Gradle project and the pod keep their names, so quick-crypto links against the copy. cryptoand theIntlconstructors Hermes lacks are made of packages the library carries too (VENDORING.md):react-native-quick-crypto1.1.3 (crypto,crypto.subtle, and the Nodecryptothat libraries written for Node import),react-native-quick-base642.2.2 (the base64 module it asks for) andhermes-intl0.1.2 (Intl.PluralRules,RelativeTimeFormat,ListFormat,Locale), beside the Nitro runtime and MMKV. None is a peer dependency any more,svelte-native initdoes not install them,svelte-native doctorno longer asks for them among the app's dependencies, and an app that still lists one is refused (the prebuild stops,doctorfails, the autolinking commands refuse it), as for MMKV and the Nitro runtime. To move an app over: remove the three from itspackage.jsonandreact-native-quick-cryptofrom the plugins of its Expo config, install again, prebuild again and rebuild. quick-crypto's own JavaScript dependencies (@craftzdog/react-native-buffer,events,readable-stream,safe-buffer,string_decoder,util) are dependencies of the library now, installed with it; a package manager still installsreact-native-quick-base64beside the library for the Buffer package's sake, which is inert (the library's copy is the one linked and bundled). The package gains about 14 MB unpacked, 3.7 MB compressed (9.4 MB of it hermes-intl's prebuilt ICU4X libraries); an app's installed size does not change, since it installed the same code before, and its native code is the same.- The Expo plugin option of quick-crypto that apps used,
sodiumEnabled(libsodium forcrypto: XSalsa20 and the other ciphers OpenSSL lacks), is an option of the library's plugin:["@alfayez/svelte-native", { sodiumEnabled: true }]in place of["react-native-quick-crypto", { sodiumEnabled: true }]. It writes the same settings (Android:sodiumEnabled=trueingradle.properties; iOS:ENV['SODIUM_ENABLED'] = '1'at the top of the Podfile) and removes them again when the option is off. quick-crypto's other plugin step, which set every pod's iOS deployment target to 16.4, is not carried: ExpoModulesCore and the library's pod need 16.4 already. - The library carries
react-native-gesture-handler2.32.0,react-native-reanimated4.5.1,react-native-worklets0.10.1 andreact-native-svg15.15.4 too (VENDORING.md), with its patches to the first three applied to the copies (vendor-patches/): they are no peer dependencies any more,svelte-native initdoes not install them, and an app that still lists one is refused, by the prebuild,svelte-native doctorand the autolinking commands, with the one message (remove it from the app's dependencies, install again, prebuild again;initprints it for a proj...
@alfayez/svelte-native 0.4.0-rc.8
Added
- The library's own
fetch, on a native module of its own (SvelteFetch, in the newnative/svelte-core: URLSession on iOS, React Native's OkHttp client on Android, so cookies and the app's interceptors are shared with React Native's networking). On the device the library installsfetch,Headers,Request,Response,Blob,File,FileReaderandFormDatain place of Expo's and React Native's, andURL.createObjectURLandURL.revokeObjectURL; each global is a getter that loads its implementation on the first read, so the start-up loads none of it, and an app binary without the native module keeps Expo'sfetch. A response's bytes stay native until the code reads them:arrayBuffer()andbytes()hand JavaScript one native buffer (no base64, no copy through a JavaScript array),blob()keeps them native, andbodyis aReadableStreamthat reads them in 64 KiB chunks as they arrive (the transfer pauses while more than 1 MiB is unread). ABlobis native bytes too: joining,slice, uploading one and a multipart body built from them copy nothing through JavaScript, andURL.createObjectURL(blob)gives afile://URL an image, a video or a WebView loads.fetchtakes http(s),data:,file://and (Android)content://URLs;redirectisfollow(up to 20),errorormanual(the redirect response itself, as Node'sfetchgives it);credentials: "omit"sends no cookie and keeps none; anAbortSignalstops the request or the body (andAbortSignal.timeoutandAbortSignal.anyexist);text()decodes UTF-8 as the standard says (a byte order mark dropped, an invalid sequence U+FFFD).FormDataextends React Native's, soXMLHttpRequestand axios still send it, andxhr.send(blob)sends one of the library's Blobs (as a file the library writes and deletes when the request ends); a caller'sContent-Type: multipart/form-datawithout the body's boundary gets it, as React Native's and Expo'sfetchdo. AFormDatavalue may be React Native's{ uri, name, type }, read natively as it is sent;blob:URLs of React Native's own Blobs still fetch. On Android ablob()past 16 MiB is kept in a cache file, and a body too large for memory rejects instead of crashing the app. Request bodies are sent whole: aReadableStreambody is read to its end first, and an abort meanwhile rejects at once and cancels the stream with the signal's reason.mode,cache,referrerandintegrityare accepted and ignored. On iOS a repeated response header arrives joined with ", " (Set-Cookie too),statusTextis the standard phrase for the status, and a POST body that has no type (bytes, or a Blob without one) goes out asapplication/octet-stream, because URLSession would otherwise label itapplication/x-www-form-urlencoded. - The showcase's "Web APIs" screen: a docs video downloaded as a body stream with a progress bar, its SHA-256 from
crypto.subtle, a picture fromresponse.blob()through an object URL,crypto.randomUUID(), and a visit count inlocalStorage. Opened with?checks=<origin>, it runs device checks offetch,Blob,crypto,localStorageandnavigatoragainst the library's test server (tests/fetch/server.ts) and logs each as[web-apis] …. cryptoandlocalStorageon the device, the web's own with nothing to import.cryptoisgetRandomValues,randomUUIDandsubtle(the Web Crypto API) from react-native-quick-crypto, native code on OpenSSL; a library that importscryptoornode:cryptogets react-native-quick-crypto itself, with Node's API (Metro resolves it).localStorageis the web'sStorage(getItem,setItem,removeItem,clear,key,length, keys as properties) on an MMKV instance, so it is synchronous and survives a restart;sessionStorageis the same in memory for the app's process. Nothing loads until the name is first read.@alfayez/svelte-native/mmkvhas react-native-mmkv'screateMMKVand types, andlocalStorageMMKV(), the instance behindlocalStorage. On a binary without the native libraries (an over-the-air update onto an older build)cryptoandlocalStorageread asundefined, with one warning. Guide: Native features, "Web APIs".- The guide's "Web APIs" page (Native features):
fetch,Blob,File,FormData,cryptoand storage on the device; its crypto and storage sections moved there from "Platform APIs". src/hooks.mobile.ts(or.js), the native app's counterpart of SvelteKit'shooks.client.ts. Its top level runs right after the library's start-up and before the app's layout and routes (the modules the file imports run just before it), the place for a crash reporter's set-up or a background task'sTaskManager.defineTask.initruns once when the app's JavaScript starts, in a launch without a screen too; the first screen waits for the promise it returns (the splash screen stays up), and a surface the host stops meanwhile never starts.handleErrorandtransportare the remote functions' (SvelteKit's client hook, and thetransportof the universal hooks, which the file can re-export from./hooks);configureRemote({ transport, handleError })still replaces them, and an app that uses no remote function loads nothing of SvelteKit for them. A failedinit(a throw or a rejection) is a fatal error in a release build; in development it is the error screen, and the screen's Reload or the next edit of the file runsinitagain (an edit saved whileinitis still in flight runs once it has failed). A hot update of the file applies its new exports and remounts the screens without runninginitagain; the development server writes the generated.svelte-native/hooks.tsagain when the file is added or removed, and removing it drops its hooks. A hot update that runsinit(the file added to a running app, or fixed) keeps the screens and their navigation until it has finished, then remounts. The generated entry imports./hooksafter@alfayez/svelte-native/app, so a Metro that keeps the entry rewrites one without it.bootSummary()has ahooksphase (the file's evaluation) and, for aninitthat returns a promise, ahooks initone. Guide: Core concepts, "Hooks".- File fields in remote forms:
fields.x.as("file")andas("file multiple")givevalue,multipleandonValueChangefor a picker of the app's, which passesFiles (the library's own on the device:new File([await (await fetch(uri)).blob()], name, { type })keeps the bytes native from the file to the request). The submission is the binary form SvelteKit's server parses, with each file as SvelteKit lays it out, so the server action gets an ordinaryFile. A form without files is sent as before. On a build without the library's fetch module (an over-the-air update onto an older build), a submission with a file fails (form.erroris SvelteKit's default 500), and theTypeErrorthe app'shandleErrorgets names the build it needs.validate()of a form with files sends them, as SvelteKit's form does.as("image")still throws.NativeFilePropsis the props' type (@alfayez/svelte-native/remote). Guide: Core concepts, "Loading data", "Forms". - A remote form submission that fails on the fields' issues (the preflight's or the server's) focuses the first input with an issue, in the order the inputs were made, among those on screen whose host can take focus. Validating alone never moves the focus.
navigatoron the device:navigator.clipboardandClipboardItem(the async Clipboard API over the system clipboard, through a new native module of the library's,SvelteClipboardinnative/svelte-core:readText,writeText, andreadandwriteoftext/plainandtext/html; another type is refused withNotAllowedError; iOS shows its paste prompt on a read, and Android reads as empty while the app has no focused window),navigator.shareandnavigator.canShare(the Web Share API on the system share sheet: a title, a text and an absolute URL, no files; a dismissed sheet is anAbortErroron iOS, and Android does not report one),navigator.vibrate(a duration or a pattern,0or[]stops, a call replaces the pattern playing; iOS starts its one fixed vibration at each of the pattern's vibrations) andnavigator.languageandnavigator.languages(a BCP 47 tag: Android's locale at start, Java's formzh_CN_#Hansturned intozh-Hans-CN; on iOS, where React Native reports none, the runtime's default locale). Each loads what it is made of on first use; the clipboard module is registered lazily (the expo-modules-core patch, so runsvelte-native initagain to update the app's copy) and, on a build without it,navigator.clipboardreads asundefinedwith one warning. The showcase's Web APIs screen copies a UUID and shares a link, and its device checks are 33 (a clipboard round trip, an HTML item, and the language,canShareandvibrate). Guide: Native features, "Web APIs", "navigator".- Capabilities: web APIs that need a permission of the system are off until the app says why it uses them, in the config plugin's new
capabilitiesoption. The first islocation: with expo-location installed,capabilities: { location: "Shows the stores near you." }gives expo-location's plugin that text (iOS'sNSLocationWhenInUseUsageDescription), or{ whenInUse, background }for its background APIs too. The prebuild stops on a capability without its library, on expo-location installed without the capability (so Expo's generic "Allow $(PRODUCT_NAME) to access your location" never ships), on the capability while expo-location is left out of autolinking (the plugin'sautolinkingExcludeorexpo.autolinking.exclude), and on the capability together with expo-location's own plugin entry; an app that lists only that entry, or leaves expo-location out of autolinking, needs no capability. Withoutbackgroundthe Always texts and the background mode are left out;motiongives the ...
@alfayez/svelte-native 0.4.0-rc.7
Added
- Media queries work on the device. React Native has no
window.matchMedia; the library now installs one when the app starts (a function that loads its implementation on the first call, so the start-up reads nothing from the system), soMediaQueryfromsvelte/reactivityand shared web code that callsmatchMediano longer throwwindow.matchMedia is not a function.new MediaQuery('(min-width: 600px)').currentis reactive in a template,$derivedor$effect;window.matchMedia(query)returns aMediaQueryListwithmatches,media(as a browser writes it),onchange,addEventListener('change', listener, { once, signal })(an abort removes the listener) andremoveEventListener, the olderaddListenerandremoveListener, anddispatchEvent; achangeevent hasmatchesandmediaand comes only when the answer flips, and a list listens to the system only while it has a listener. Understood: comma lists,not,only,and,or, parentheses, the media types (allandscreenmatch,printand the rest do not), and the featureswidthandheight(min-,max-, the range syntax(width >= 600px)and(400px <= width < 700px);px,emandremas 16px, other absolute units,vw,vh,vminandvmaxof the window, a unitless0, negative lengths),device-width,device-heightanddevice-aspect-ratio(the screen's),orientation,aspect-ratio,resolutionand-webkit-device-pixel-ratio(the window's pixel ratio),prefers-color-scheme(the system's mode),prefers-reduced-motion(Reduce Motion),prefers-contrast(morewith iOS's Increase Contrast or Android's high contrast text),prefers-reduced-transparency(iOS's Reduce Transparency),inverted-colors(the system's color inversion),forced-colors(none),update(fast),scripting(enabled),color-gamut(srgb),hoverandany-hover(none),pointerandany-pointer(coarse),display-mode(standalone) andcolor. A feature the device does not have and a value it does not take are unknown, as in Media Queries 4: false alone, andnotleaves them unknown, but(foo: bar) or (min-width: 600px)is what the width says andandwith a false part is false. A query that does not parse isnot all(false; the rest of a comma-separated list still decides), andmediasaysnot allfor a query that can never be true; nothing throws. Guide: Core concepts, "SvelteKit modules", "Media queries". - The showcase's "SvelteKit modules" screen shows two media queries,
(orientation: portrait)and(prefers-color-scheme: dark), that change when the phone turns or the scheme switches.
Changed
-
svelte/motionis Svelte's own module on the device again: Metro no longer resolves it to a library file.prefersReducedMotionis Svelte'sMediaQueryof(prefers-reduced-motion: reduce)on the newmatchMedia, so it still reads the system's Reduce Motion setting, is reactive, and isfalseuntil the system has answered.Spring,Tween,springandtweenedare unchanged. -
An app's type checker (
tsc,svelte-check, the editor) reads generated type declarations, not the library's source. The package shipsdist/types/(a.d.tsfor each public entry and what it reaches, a.svelte.d.tsfor each component; built bypnpm buildwith TypeScript and svelte2tsx, committed likedist/node/), and thetypescondition of every public entry names it where it named the TypeScript and Svelte sources, which the checker parsed and checked as if they were the app's own (skipLibCheckdoes not skip a.tsfile). An app that importsViewandTextfrom the main entry, with the package installed from its tarball:tsc --extendedDiagnosticsmakes 1,146 instantiations where it made 12,997, checks in 0.02 s (0.47 s) and takes 0.41 s in all (0.95 s), with 607 files in the program (619) and 112 MB (158 MB);svelte-checkon a one-screen app takes 0.85 s (1.6 s) and loads 610 files (693). The files that remain are React Native's, Reanimated's, react-native-svg's (Reanimated's own declarations import it) and the gesture handler's declarations, which the main entry names because it exports the animation, gesture and SVG APIs (TypeScript loads every module a barrel names, whatever the app imports from it);@alfayez/svelte-native/corealone loads 234 files and neither Reanimated nor react-native-svg. Nothing changes for Metro and Vite: they resolvedefault, the same sources as before. The declarations resolve withmoduleResolution: "bundler", which SvelteKit's tsconfig sets; undernode16ornodenexta./X.svelteinside them resolves toX.d.svelte.tsand the components are untyped, as with every library built withsvelte-package: usebundler. -
The props type of the primitives no longer names Reanimated:
AnimatedView's props type moved from@alfayez/svelte-native/elementsinto the component, so/core(View,Text,Pressable, ...) and/elementsload no Reanimated declaration (the main entry still does, forAnimatedViewand the animation functions).NativeAnimatedViewPropsis no longer exported from/elements. -
Every typed entry of the exports map has a
svelte-native-sourcecondition (the TypeScript or Svelte file) beforetypesanddefault. Only this repository sets it (customConditions: ["svelte-native-source"]in the tsconfigs of the package and the apps), so it checks againstsrc/without a rebuild; an app does not, and resolvestypes./remote/runtimeand/remote/globalshave no declarations (Metro substitutes them; an app imports neither). The declarations do not reference React Native's internal modules or loadreact-native-internals.d.ts. Two of them are named for a case-insensitive file system: the router's module isdist/types/router.svelte-module.d.ts, next to the component'sRouter.svelte.d.ts. -
svelte-native sync's entry is rewritten by Metro when it is stale: a Metro that keeps the generated.svelte-native/entry.ts(so that it does not revert one a sync withSVELTE_NATIVE_ROOTwrote) now rewrites an entry that imports a path the package no longer exports (/init,/polyfillsand/fabric, which every entry written by 0.4.0-rc.5 and earlier imports) or the name before the rename (@rasheed/svelte-native), so an upgraded app starts withexpo startand nosvelte-native sync. -
svelte-native initin an app configured in code (app.config.*, noapp.json) that names the plugin@alfayez/svelte-native/exposays to replace it with@alfayez/svelte-native, where it said to add the plugin.
Removed
- The import paths 0.4.0-rc.6 deprecated no longer resolve, so an import of one fails to resolve in Metro, Vite and TypeScript. Import
@alfayez/svelte-native/animationand@alfayez/svelte-native/gesturesfrom@alfayez/svelte-native, with the same names. Import@alfayez/svelte-native/svgfrom@alfayez/svelte-nativetoo, whereText,Image,LinearGradientandMarkerareSvgText,SvgImage,SvgLinearGradientandSvgMarker, andSvg, which was the default export, is a named one (import { Svg } from "@alfayez/svelte-native"). ImportturboModuleandnativeModule(@alfayez/svelte-native/native-modules) from@alfayez/svelte-native/platform. @alfayez/svelte-native/expois not a name of the config plugin any more: write"@alfayez/svelte-native"inpluginsofapp.jsonorapp.config.*, with the same options, orexpo prebuildstops withPLUGIN_NOT_FOUND.svelte-native initreplaces the entry in anapp.json(and keeps its options), andsvelte-native doctorfails on a config that lists the path, saying to write the package's name in its place (up to 0.4.0-rc.6 it passed with a note).@alfayez/svelte-native/init,/polyfillsand/fabricare gone: runsvelte-native sync, and the generated.svelte-native/entry.tsimportscreateFabricAppandremountSurfacesfrom@alfayez/svelte-native/app, which also loads the boot modules in order. An entry of your own that imports them does the same (/appexportscreateFabricApp,remountSurfaces,showError,fabricStatsandflush).
@alfayez/svelte-native 0.4.0-rc.6
Added
- SvelteKit's built-in modules work on the device, with the same imports as on the web, so a file shared with SvelteKit pages needs no change (Metro resolves each import to the library's own file).
gotofrom$app/navigationdrives the app's root router from any code, a component or not, and takesreplace(andreplaceState),preloadCode(routeId)loads a screen's code, anddisableScrollHandlingdoes nothing;reset,refreshAll,invalidate,invalidateAllandpersistStateare ignored andshallowandstatereject, since there is nopage.state.beforeNavigate,afterNavigate,onNavigate,snapshot,invalidate,invalidateAll,refreshAll,preloadData,pushStateandreplaceStateare declared by SvelteKit but have nothing behind them on a device: each throws`name` is not available on the device yet (svelte-native)and why when called.pagefrom$app/statefollows the screen the user sees now, through the stacks, tabs and modals (url,params,route.idas SvelteKit writes it,/(app)/posts/[id]), in any component or module; it is the top screen's wherever it is read, since the screens below it stay mounted, so a screen reads its own data from itsparamsandurlprops and usespagefor what concerns the whole app;statusis 200,dataandstateare{},form,errorandshallowarenull, andnavigatingalways has the shape of no navigation.updatedis backed by the over-the-air updates:currentis true once a check found an update or one was downloaded (byfetchUpdateAsyncor the check at launch too), andcheck()asks the server (false when updates are off).$app/pathshasresolve(route ids with dynamic, optional and rest parameters, groups and escapes),asset,match, andbaseandassetsas empty strings. A bareimportof$app/forms,$app/stores,$app/manifest,$app/service-worker,$app/env/publicfails the bundle with a message naming the module, and$app/env/privateis refused like$app/server. Guide: Core concepts, "SvelteKit modules". mobilefrom$app/env(and$app/environment, the name SvelteKit 3 deprecates it under) istrueon the device andfalsein the web build, for code shared between them:{#if mobile}. On the device$app/envalso hasbrowser(false),dev(__DEV__),building(false) andversion(the app config'sversion, read byexpo-constants). On the websvelteNative()invite.config.tsre-exports SvelteKit's own module withmobile = false, invite devand in the client and server builds, and the constant is folded in a production build. The type is declared by the library, which an app's type check reaches through@alfayez/svelte-native/viteand the router; nothing to add toapp.d.ts.svelte/motionworks on the device. Svelte's own module throwswindow.matchMedia is not a functionwhen it is imported, because it buildsprefersReducedMotionfrommatchMedia; Metro now resolves the import to a module that loads Svelte's (Spring,Tween,spring,tweened) and replacesprefersReducedMotionwith one that reads React Native's reduce motion setting and follows its change event, reactive like Svelte's.router.preload(route)loads a route's modules and settles when they are loaded, androotRouter()(@alfayez/svelte-native/router) is the app's root router, reactive, from the moment its component creates it to the moment it is gone.
Changed
- One import for the library:
@alfayez/svelte-nativealso exports everything/animation,/gesturesand/svgdid, andBlurView(the library's own blur;/foreignstill exports it too).import { View, Text, AnimatedView, Gesture, createSharedValue, withSpring, Svg, Path } from "@alfayez/svelte-native"works. Reanimated and the gesture builders still load on first use, not when the app starts; the main entry now evaluates the animation, gesture and SVG modules at start, which/animation,/gesturesand/svgdid only for an app that imported them. - Four SVG elements take another name in the main entry than react-native-svg's:
TextandImageareSvgTextandSvgImage, becauseTextandImageare the views there (the compiler lowers those two to native elements;SvgTextandSvgImageare left as components), andLinearGradientandMarkerareSvgLinearGradientandSvgMarker, because/foreignhas aLinearGradient(expo-linear-gradient) and aMarker(maps) of its own. The other SVG names are the same, and the main entry exports no name that/foreignalso exports for a different component. react-native-svg(15.15.4) is a required peer dependency: the main entry exports its components, so every app has it.svelte-native initadds it topackage.json,svelte-native doctorfails when it is missing or out of range (it was an optional peer, skipped), andexamples/minimallists it. An existing app runspnpm add react-native-svg@15.15.4, thennpx expo prebuildif it did not have it.turboModuleandnativeModuleare exports of@alfayez/svelte-native/platform, withPlatform,Dimensionsand the rest of the platform modules. They still load React Native's registries on their first call.- The Expo config plugin is named by the package,
plugins: ["@alfayez/svelte-native"](Expo loads the package'sapp.plugin.js), whichsvelte-native init, the guide and the example apps write now;@alfayez/svelte-native/app.pluginis the same file.svelte-native doctoraccepts all three names (/expotoo, with a note that it is deprecated). - The generated entry (
.svelte-native/entry.ts) is one import,import { createFabricApp, remountSurfaces } from "@alfayez/svelte-native/app", where it was three (/init,/polyfills,/fabric)./apprunsinit, thenpolyfills, then loads the Fabric host, as before, and exportscreateFabricApp,remountSurfaces,showError,fabricStatsandflush. An entry written by an earlier release keeps working untilsvelte-native syncrewrites it (svelte-native dev,android,iosandbuildrun it). Apps do not import/appthemselves. use:gestureworks from the main entry (import { gesture } from "@alfayez/svelte-native") as it did from/gestures: no warning about an action on a native element.- The remote function runtime and its globals stay two internal entries (
/remote/runtime,/remote/globals): SvelteKit's client files import the globals and the runtime imports those files, so one module for both would import itself. An app does not import either. gotoandrouter.gototo the screen the user is on, with another search or hash (goto('?tab=3'),goto('#top')), change that screen'surlin place (itsurlprop andpage.urlupdate) instead of pushing or replacing a screen, so the page is not built again;reset: truestill makes a new first screen.goto,router.goto,matchandpreloadCodecalled in an$effectno longer make it run again for the screens the user pushes.goto'sreplacewins overreplaceStatewhen both are given, as in SvelteKit.
Deprecated
@alfayez/svelte-native/animation,/gestures,/svg(itsText,Image,LinearGradientandMarker, andSvgas its default, keep their names),/native-modules,/expo,/init,/polyfillsand/fabricstill work in this release and are removed in 0.4.0-rc.7. Import from@alfayez/svelte-native(animation, gestures, SVG),@alfayez/svelte-native/platform(turboModule,nativeModule), name the plugin@alfayez/svelte-native(/expo), and runsvelte-native syncfor/init,/polyfillsand/fabric(the entry imports/app). An editor strikes the deprecated names through (@deprecatedon each export); nothing is logged when the app runs.
@alfayez/svelte-native 0.4.0-rc.5
Changed
- The package is
@alfayez/svelte-native, no longer@rasheed/svelte-native. Change the dependency's name inpackage.jsonand every import (@rasheed/svelte-nativeand its subpaths,/foreign,/metro,/vite, ...) to@alfayez/svelte-native; nothing else changes.pnpm packwritesalfayez-svelte-native-<version>.tgz.
@rasheed/svelte-native 0.4.0-rc.4
Added
-
HTML elements are native components in an app's own files (not in
node_modules, never in the web build):div,section,ul,li,form,dland the rest are views,p,span,h1–h6,strong,code,mark,kbdand the other text elements are texts,prekeeps its whitespace,bris a newline,hra hairline,buttonanda hrefare pressables (a path goes to the router,https:/mailto:to the phone),imgis an image (src,alt,width,height),inputandtextareaare aTextInput(typepicks the keyboard,bind:value,oninput,onkeydown), a checkbox is aSwitch,dialogis aModal(open,bind:open). One.sveltefile can be a SvelteKit page and a screen.onclickisonPress; text directly in adivis drawn by the host in a text of its own;<form onsubmit>hears a submit button and Enter in an input, wherever the components are; astyle="..."string is converted when the file is built, andstyle:propertydirectives follow their values; a web handler that cannot run on a device is a build warning, an element or an attribute with no native equivalent is a build error that names it and says what to use. Text style set by an HTML element (class="text-lg text-white",style="color: white") reaches the texts and inputs below it, as CSS does, through anyViews between;leading-*andtracking-*are made from the font size the text ends up with.docs/20-core-concepts/50-html-elements.mdis the page; the showcase has an HTML screen. The renderer gainshostHtmlClass,hostWebSpread,hostWebClickSpread,hostSource,hostInputEvent,hostKeyEvent,hostClick,hostHref,hostSubmit,hostStyleProps,hostBind,hostTagandhostInline(what the lowered code calls),router.svelte.tsgainsuseLink, and anImagetakeswidth,heightandaltas React Native's does. The text that is bare in an HTML view is drawn by the host when it runs, so text fromchildren, a snippet or a block shows (<button>{@render children?.()}</button>), and in a block container a run of text and inline elements (Hello {#if n}{n}{/if}!, two spans) is one line, while a flex container (display: flex, or a direction, gap, wrap,justify-content,align-itemsoralign-content) lays out items: each element is one, and each run of text between them (<div class="flex-row justify-between"><span>Name</span><span>{price}</span></div>); an inline element with adisplayof its own (<span class="block">) is an item of its own (inline,inline-blockandinline-flexflow, andnoneneither breaks the line nor takes part in it), and so is an<a>in a component of its own; development warns once when flex keys are on a text element, which does nothing there; an element that is a text of its own and then a span of a line (or the other way round) when the content around it changes is built again as the component it now is; elements have a browser's default style (boldb, italicem, monospacecode, headings at 2 to 0.67 em, ...) under their class and style; a component that passes{...rest}down keeps its meaning (a button'stypeandonclick, an input'stype,disabled,maxlength,oninput, a link'shref);<svelte:element this={tag}>draws the host tag oftag(bind:thisand a tap on it work:onclickandon:clickareonPress),<svelte:head>is taken out and<svelte:window>is an error; an unknown tag is a build error; on an element written outon:click={f}isonPress, any otheron:event={f}isonevent={f}, and a modifier (on:click|preventDefault) is a build error that says what to write;use:and the transition directives on aninput,textareaordialog(components, which take none) are left out with a warning. Nested decorations add up (<u><s>). The class compiler writes the keyword of adisplayit maps toflex(block,inline-block) ashtmlDisplaybeside it, a style key the native view ignores.bind:thisgives the handle beforeonMountand follows its row in a keyed{#each};Modaltakesopenandbind:open. -
asyncoption ofwithSvelteNative(config, { async: true })(andsvelteNative({ async: true })for the Vite plugin) turns on Svelte's async mode (experimental.async, experimental in Svelte) for every Svelte file the transformer compiles, the library's own and a library's belownode_modulesincluded, and is part of Metro's cache key. It allowsawaitin$derived, in the markup and at the top of a component. With it on,tick()waits for the next frame or a timer instead of a microtask, and the components of different blocks that change in one update run their$effect.preand their teardown in another order; the tree and each component's own calls are the same. Off by default. -
router.prepare(href, navigation?)(experimental) renders the screen of a navigation off screen while a gesture runs (Svelte'sfork()), andcommit()puts it on when the finger lifts,discard()drops it;PreparedNavigationis its type. It needs theasyncoption above; without itcommit()is a plaingoto. Bothfork()and async mode are experimental in Svelte, so this may change.SVELTE_NATIVE_TEST_ASYNC=1 bun test(alsomicrotask) runs the package's tests with async mode on. See the router's page in the reference and Routing, "Preparing a screen". -
Svelte's own
transition:,in:,out:(svelte/transition) andanimate:flip(svelte/animate) work on native elements, written as on the web on HTML elements (<div in:fly>,<li animate:flip>in a keyed{#each}; also on the lowered primitives,<View in:fly>,Text,ImageandPressable, and on the host tags), and play on the UI thread through Reanimated: a busy JavaScript thread does not make them stutter. Svelte decides when they run and works out their frames; the library samples them as tracks of oneanimatedStyleworklet per node, driven by a linearwithTimingshared value, sofade,fly,scale,slide,blurand your own transitions play, anin:that is turned into anout:goes on from where it was, andanimate:flipmoves each item of a keyed{#each}from where it was (the layout is read synchronously from the committed tree; an item that leaves is held in place withposition: absolutewhile it fades). Played properties:opacity,transform(translate,scale,rotate,skew,perspective), lengths and percentages (height,width,padding*,margin*,border*Width, ...) and colours; opacity and transforms take the Android engine's direct write path, lengths go through Reanimated's shadow-tree commit (a layout pass per frame, soslidecosts more thanfade). Dropped with a one-time warning in development, the rest still playing:filter(soblurfades without blurring), SVG stroke properties (draw),matrix()and the 3D transform functions; atick-only transition runs on the JavaScript thread. An element in its outro takes no touches (pointerEvents: "none"). The compiler of the custom-renderer build refuses these directives, so the Metro transformer removes the two refusals from the compiler's sources as it loads them (module.registerHooks, Node 22.15 or newer; no patch to install, and an app's Svelte can be the stock tarball of the guide);<View in:fly>compiles in Metro but svelte-check reports a directive on a component, so write the directives on HTML elements (<div in:fly>, which the build turns into a native view and svelte-check accepts). A span or other text inside a paragraph runs its transition's length and draws nothing: React Native draws it as part of the paragraph. -
windowSize(width,height,scale,fontScale,screen) is the window's size as state, likecolorScheme: a template,$derivedor$effectthat reads it runs again when the window changes, all readers sharing oneDimensionslistener. Svelte's ownsvelte/reactivity/window(innerWidth,innerHeight,devicePixelRatio, ...) reads the same values on the device, so a component shared with the web needs no change; Metro resolves the import to the library's version. -
BlurViewin@rasheed/svelte-native/foreignis the library's own blur and needs noexpo-blur: it blurs what is drawn behind it, withintensity(0 to 100) andtint(expo-blur's names) and the children on top (the engine's views, so they take touches). iOS uses aUIVisualEffectView; Android 12 and up draws the window behind the view into a small picture each frame and blurs it on the GPU, and older Androids draw a translucent tint. It is a new native module of the library (native/svelte-blur), so the native host has to be rebuilt. -
classon components, with Tailwind 4:withSvelteNative(config, { css: "src/global.css" })compiles the app's CSS file (Tailwind's utilities,@theme, your own classes) to React Native styles when Metro starts, writes them to.svelte-native/classes.<variant>.tsand rewrites that file when a source changes, so the screens update in place; nothing is imported and no CSS runs on the device.classtakes a string, an array or an object (andclass:nameon the primitives a page compiles to native elements);dark:, breakpoints andenv(safe-area-inset-*)follow the system's appearance, the window and the insets; an inlinestylewins. A class with no native equivalent (hover:,grid, transitions, ...) is left out and warns in development when it is used.svelte-native css <file>runs the compile by hand.tailwindcss@4.3.3is an optional peer dependency. (This replaces the Uniwind integration that was onmainbriefly and never released.) The showcase has a Classes screen; the guide's Styling page has "Classes".
Changed
- A
refis called as soon as the element is on the screen (it was a microtask later, when the host built the view), soonMountand effects find the handle (an element of a screen th...
@rasheed/svelte-native 0.4.0
The early preview: an app starts from npx sv create, adds the library with pnpm add and runs svelte-native init (the guide is docs/). Checked on the release branch: the package, harness and showcase tests, the engine's host checks, the consumer check in its three modes (tarball, git and the guide's starter path, each through a Gradle build), the starter on the OVH emulator to its second screen, and the showcase on the Samsung A16 (the generic camera and image views, the scroll clip under a plain header, the status bar) and the iPhone SE 3 (ExpoView checked by hand; the release build launches). The device suites of native-qa were not run again for this release: PLAN.md has their last full round, on 0.3.0.
Added
svelte-native initturns a SvelteKit project (npx sv create: minimal template, TypeScript, pnpm) into a Svelte Native app, afterpnpm addof the library: the custom-renderer Svelte, the peers at the versions the library was exercised on, SvelteKit pinned to the version it patches,main, the Reanimated flag, the scriptsnative,android,iosandcheck-setup(dev,buildandcheckstay SvelteKit's), pnpm'sallowBuilds,overridesandpatchedDependenciesmerged into the project'spnpm-workspace.yaml, the patch files,metro.config.cjs,app.json, the Vite config (svelteNative()around SvelteKit's plugin, when the file has the shapesvwrites; otherwise the change is printed), the first native routes when there are none, and the.gitignoreentries; thenpnpm installand the doctor.--dry-runprints the plan, a second run changes nothing, a file it cannot change safely is left alone, and--name,--android-package,--ios-bundle-id,--forceand--no-installare the options. It loads neither Svelte's compiler nor Metro, so it runs before the project is set up.svelte-native --helplists the commands.- The guide,
docs/: creating a project fromnpx sv create, the project structure, native routes, development builds andexpo prebuild, native libraries, adding the library to an existing Expo app, and troubleshooting. scripts/consumer-check.sh starter: the path of the guide,sv create,pnpm addof the local package,svelte-native init(and again, which must change nothing),pnpm check, the web build, and the native stages after them.
Changed
- SvelteKit 3.1.1 is the supported version, instead of 3.0.0-next.27. It is what
sv createinstalls. The patch is regenerated for it (patches/@sveltejs__kit@3.1.1.patch) and the peer is3.1.1; the version of the prerelease is no longer supported (the doctor and its tests know one patch per package). Reviewed against the prerelease: the error and warning messages of SvelteKit's client runtime moved to message modules (Metro resolves them, andesm-envstill givesBROWSER), prerender'sFinalizationRegistryis no longer guarded (the library's stand-in is injected where the runtime is compiled),query.liveasks fortext/event-stream, andfor(key)form instances are held from inside the effect (ported toremote/form.svelte.ts). The QA app's bundle is 91,291 bytes (1.6 %) larger from SvelteKit's runtime. examples/minimal's doctor script ischeck-setup(pnpm doctoris pnpm's own command), as in the showcase.- The doctor's fix for a Svelte that is not the custom-renderer build, and for a missing dependency on the library, point at
svelte-native initand the README section that holds the instructions ("Install in an app"); they named "Set up an app".
Fixed
- An app is held to the Node a fresh install accepts, not to the repository's. A new
sv createapp on Node 25, the Node the doctor asked for, stopped at its firstpnpm addwithERR_PNPM_UNSUPPORTED_ENGINE: React Native asks for@react-native/metro-configby a range, so the install took 0.88 beside React Native 0.86.3, and its tools (and Metro 0.87) exclude Node 25.svelte-native doctornow asks an app for^22.17.0 || ^24.3.0 || >=26.0.0(Node 24 LTS first) and the repository's own apps for>=25.0.0, with a fix text for each;svelte-native initpins@react-native/metro-configto React Native's version inoverrides(examples/minimaldoes too); the guide and troubleshooting name the Node to use and show the Node 25 error; the consumer build runs on Node 24. - A SvelteKit app's
svelte-checkis clean without setup.watchRoutesno longer calls.unrefonReturnType<typeof setTimeout>, which a SvelteKit app's tsconfig (no Node types) types as a number, andwithWebRunestakes adynamicCompileOptionscallback of any vite-plugin-svelte release (7.3 adds Vite'senvironmentto its data), so an app needs neither@types/nodenor the 7.2.0 pin. - Android: a
<Screen>that sets nostatusBargets the default status bar appearance, and thestatusBarandnavigationBaroptions take effect at all. The engine looked for the activity through the decor view's context, which on Android 16 is the platform'sDecorContextaround the application context, soSystemBarsreturned before it wrote anything; and its first write was skipped when no option was set (appliedbegan as the spec of "no option"). The window kept the activity theme's light icons: a white clock on the light header of a fresh app. The icons now follow the system appearance, dark by day and light at night, as the engine's header does. Checked on an emulator in light mode; the rules are a host check (SystemBarsRulesCheck).
@rasheed/svelte-native 0.4.0-rc.3
Fixed
- After the library was updated (a new tag of the git dependency), Metro could keep bundling the old version from its caches, even after a restart: an app updated to 0.4.0-rc.2 failed with
Cannot read property 'current' of undefinedbecause it still ran 0.4.0-rc.1, which has nocolorScheme.withSvelteNativenow records where the installed library is (.svelte-native/metro-library) and starts Metro with empty caches once when that changes, as--clearwould.
@rasheed/svelte-native 0.4.0-rc.2
Added
colorScheme.current(import { colorScheme } from "@rasheed/svelte-native"): the system's light or dark mode, reactive like Svelte'sprefersReducedMotion. A template,$derivedor$effectthat reads it runs again when the user switches; its readers share one listener on React Native'sAppearance, removed when the last of them goes.
Fixed
- The first routes
svelte-native initwrites were unreadable in dark mode: their texts had no colour, so they were black on the dark window. They now take their colours from a themeinitwrites,src/lib/theme.ts(native-theme.tswhen the app has atheme.tsof its own), which followscolorScheme. - The screens of
init's layout had no background, so the details screen drew over the home screen while it was pushed. The layout is now a<Stack>that gives every screen the theme's background, and a status bar that follows the mode. - Android: after a switch between light and dark while the app was open, the status and navigation bar icons kept the old appearance (white on a light bar after a switch to light); a cold start drew them right. The
autostyle now follows the switch.
@rasheed/svelte-native 0.4.0-rc.1
The early preview, a release candidate for friends to try: an app starts from npx sv create, adds the library with pnpm add and runs svelte-native init (the guide is docs/). Checked on the release branch: the package, harness and showcase tests, the engine's host checks, the consumer check in its three modes (tarball, git and the guide's starter path, each through a Gradle build), the starter on the OVH emulator to its second screen, and the showcase on the Samsung A16 (the generic camera and image views, the scroll clip under a plain header, the status bar) and the iPhone SE 3 (ExpoView checked by hand; the release build launches). The device suites of native-qa were not run again for this release: PLAN.md has their last full round, on 0.3.0.
Added
svelte-native initturns a SvelteKit project (npx sv create: minimal template, TypeScript, pnpm) into a Svelte Native app, afterpnpm addof the library: the custom-renderer Svelte, the peers at the versions the library was exercised on, SvelteKit pinned to the version it patches,main, the Reanimated flag, the scriptsnative,android,iosandcheck-setup(dev,buildandcheckstay SvelteKit's), pnpm'sallowBuilds,overridesandpatchedDependenciesmerged into the project'spnpm-workspace.yaml, the patch files,metro.config.cjs,app.json, the Vite config (svelteNative()around SvelteKit's plugin, when the file has the shapesvwrites; otherwise the change is printed), the first native routes when there are none, and the.gitignoreentries; thenpnpm installand the doctor.--dry-runprints the plan, a second run changes nothing, a file it cannot change safely is left alone, and--name,--android-package,--ios-bundle-id,--forceand--no-installare the options. It loads neither Svelte's compiler nor Metro, so it runs before the project is set up.svelte-native --helplists the commands.- The guide,
docs/: creating a project fromnpx sv create, the project structure, native routes, development builds andexpo prebuild, native libraries, adding the library to an existing Expo app, and troubleshooting. scripts/consumer-check.sh starter: the path of the guide,sv create,pnpm addof the local package,svelte-native init(and again, which must change nothing),pnpm check, the web build, and the native stages after them.
Changed
- SvelteKit 3.1.1 is the supported version, instead of 3.0.0-next.27. It is what
sv createinstalls. The patch is regenerated for it (patches/@sveltejs__kit@3.1.1.patch) and the peer is3.1.1; the version of the prerelease is no longer supported (the doctor and its tests know one patch per package). Reviewed against the prerelease: the error and warning messages of SvelteKit's client runtime moved to message modules (Metro resolves them, andesm-envstill givesBROWSER), prerender'sFinalizationRegistryis no longer guarded (the library's stand-in is injected where the runtime is compiled),query.liveasks fortext/event-stream, andfor(key)form instances are held from inside the effect (ported toremote/form.svelte.ts). The QA app's bundle is 91,291 bytes (1.6 %) larger from SvelteKit's runtime. examples/minimal's doctor script ischeck-setup(pnpm doctoris pnpm's own command), as in the showcase.- The doctor's fix for a Svelte that is not the custom-renderer build, and for a missing dependency on the library, point at
svelte-native initand the README section that holds the instructions ("Install in an app"); they named "Set up an app".
Fixed
- An app is held to the Node a fresh install accepts, not to the repository's. A new
sv createapp on Node 25, the Node the doctor asked for, stopped at its firstpnpm addwithERR_PNPM_UNSUPPORTED_ENGINE: React Native asks for@react-native/metro-configby a range, so the install took 0.88 beside React Native 0.86.3, and its tools (and Metro 0.87) exclude Node 25.svelte-native doctornow asks an app for^22.17.0 || ^24.3.0 || >=26.0.0(Node 24 LTS first) and the repository's own apps for>=25.0.0, with a fix text for each;svelte-native initpins@react-native/metro-configto React Native's version inoverrides(examples/minimaldoes too); the guide and troubleshooting name the Node to use and show the Node 25 error; the consumer build runs on Node 24. - A SvelteKit app's
svelte-checkis clean without setup.watchRoutesno longer calls.unrefonReturnType<typeof setTimeout>, which a SvelteKit app's tsconfig (no Node types) types as a number, andwithWebRunestakes adynamicCompileOptionscallback of any vite-plugin-svelte release (7.3 adds Vite'senvironmentto its data), so an app needs neither@types/nodenor the 7.2.0 pin. - Android: a
<Screen>that sets nostatusBargets the default status bar appearance, and thestatusBarandnavigationBaroptions take effect at all. The engine looked for the activity through the decor view's context, which on Android 16 is the platform'sDecorContextaround the application context, soSystemBarsreturned before it wrote anything; and its first write was skipped when no option was set (appliedbegan as the spec of "no option"). The window kept the activity theme's light icons: a white clock on the light header of a fresh app. The icons now follow the system appearance, dark by day and light at night, as the engine's header does. Checked on an emulator in light mode; the rules are a host check (SystemBarsRulesCheck).