Giter Site home page Giter Site logo

tauri-sveltekit-capacitor-template's Introduction

tauri-sveltekit-capacitor-template

This is a project template for Tauri + Sveltekit + CapacitorJS.

Usage

To clone and run this repository you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

#Clone this repository
git clone https://github.com/Maxensimon/tauri-sveltekit-capacitor-template.git
# Go into the repository
cd tauri-sveltekit-capacitor-template
# Install dependencies
npm install

After you've installed all dependencies, you need to modify the capacitor.config.ts file to enter your app_name and your app_id.

You can also change the address to your local IPv4 if the automatic detection didn't work.

import { CapacitorConfig } from '@capacitor/cli';
import os from 'os';

const isDev = true; //Change to false for production

let config: CapacitorConfig;

const baseConfig: CapacitorConfig = {
	appId: '', //Put your app_id before adding, example : com.example.myApp
	appName: '', //Put your app_name before adding, example : My App
	webDir: 'build',
	bundledWebRuntime: false
};

switch (isDev) {
	case true:
		const interfaces = os.networkInterfaces();

		let address = '10.0.0.1';

		Object.keys(interfaces).forEach((interfaceName) => {
			const addresses = interfaces[interfaceName];
			if (!addresses) return;
			addresses.forEach((addressInfo) => {
				if (addressInfo.family === 'IPv4' && !addressInfo.internal) {
					address = addressInfo.address;
				}
			});
		});

		config = {
			...baseConfig,
			server: {
				url: `http://${address}:5173/`, //Change here if needed but keep the 5173 port.
				cleartext: true
			}
		};
		break;
	default:
		config = { ...baseConfig };
		break;
}

export default config;

Then, you need to generate the capacitor's android folder and ios folder.

#Generate the capacitor's android folder
npm run init:android
#Generate the capacitor's ios folder
npm run init:ios

Dev

Don't forget to put isDev to true in the capacitor.config.ts file.

#Web
npm run dev:web 
#PC
npm run dev:pc
#Android, you need to have an instance of a dev:web in another terminal to be connected to the Ipv4
npm run dev:android 
#IOS, you need to have an instance of a dev:web in another terminal to be connected to the Ipv4
npm run dev:ios 

Build

Don't forget to put isDev to false in the capacitor.config.ts file.

#Web
npm run build:web
#PC
npm run build:pc
#Android
npm run build:android
#IOS
npm run build:ios

Useful links

tauri-sveltekit-capacitor-template's People

Contributors

maxensimon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.