Overview
The sveltekit-cordova-adapter is a fork of the official sveltekit-static-adapter. It is an adapter for SvelteKit apps that prerenders the entire site as a collection of static files for use with Cordova or Capacitor. With this adapter, developers can create mobile apps for Android and iOS using SvelteKit and Apache Cordova or Ionic Capacitor. The project is free, open-source, and provides excellent free support. Donations are appreciated to support the developer’s work on the project.
Features
- Easy to use
- MIT License
- Make Android app with Svelte Kit
- Make iOS app with Svelte Kit
- Make mobile apps with Svelte Kit and Apache Cordova
- Make mobile apps with Svelte Kit and Capacitor by Ionic
Installation and Setup
Setup (Cordova)
- Create a new SvelteKit project.
- Install the adapter:
npm install @ptkdev/sveltekit-cordova-adapter --save-dev - Edit the
svelte.config.jsfile and replace the default adapter withcordova-adapter. - Run
npm run build(Important: Only pages withexport const prerender = true;are supported). - Create a new Cordova project.
- Copy the build content from the SvelteKit project and paste it in the
wwwfolder of the Cordova project. - Run the Cordova project with
cordova run iosorcordova run android.
Setup (Capacitor)
- Create a new SvelteKit project.
- Install the adapter:
npm install @ptkdev/sveltekit-cordova-adapter --save-dev - Edit the
svelte.config.jsfile and replace the default adapter withcordova-adapter. - Run
npm run build(Important: Only pages withexport const prerender = true;are supported). - Create a new Capacitor project.
- Copy the build content from the SvelteKit project and paste it in the
distfolder of the Ionic Capacitor project. - Run the Capacitor project with
npx cap sync && npx cap run iosornpx cap sync && npx cap run android.
Summary
The sveltekit-cordova-adapter is a useful tool for developers who want to create mobile apps for Android and iOS using SvelteKit and either Apache Cordova or Ionic Capacitor. It simplifies the process of prerendering the entire site as static files, making it easy to integrate SvelteKit with these frameworks. The adapter is easy to use, has an MIT License, and provides support for both Android and iOS app development.