Template for building a SvelteKit SPA with Capacitor.
Includes the following:
- Typescript
- Seemless integration with SvelteKit
Use your favorite package manager (npm, pnpm, yarn, bun, etc.)
npm install
npm run build
In order to enable live/hot reload you need to follow these steps:
Run the following command to start and host the dev server:
npm run dev -- --host
Your dev server should now start and you should see a message like this:
> - Local: http://localhost:<port>/
> - Network: http://<ip>:<port>/
Copy the network url before moving on to the next step.
Locate your capacitor.config.ts
and set the server.url
property to the network url from the previous step and set server.cleartext
to true
.
const config: CapacitorConfig = {
// ...
server: {
url: /* dev server URL */,
cleartext: true
}
};
To ensure capacitor is using the latest config, run the following command:
npx cap sync
Your live/hot reload is now ready, you can open your preferred platform IDE and run the app, any changes you make to the code will be reflected in the app without requiring you to restart it.
Keep in mind that the network url is dependant on your network so if you change networks you will need to repeat step 2. Because your IP is sensitive information, you should not commit the changed configuration to your version control system.
For further questions about Capacitor you can refer to the Capacitor Documentation.
This project is licensed under the MIT License - see the LICENSE file for details.