Everything you need to build a Svelte project, powered by create-svelte
.
Check [https://tauri.app/v1/guides/getting-started/prerequisites] to verify that you meet the necessary prerequisites.
If you're seeing this, you've probably already done this step. Congrats!
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
Change the adapter to static:
npm install --save-dev @sveltejs/adapter-static@next
Edit svelte.config.js
import adapter from '@sveltejs/adapter-static' // This was changed from adapter-auto
import preprocess from 'svelte-preprocess'
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
kit: {
adapter: adapter(),
},
}
export default config
Edit src/routes/layouts.ts[js]
so it contains the two following lines:
export const prerender = true
export const ssr = false
Install Tauri CLI
npm install --save-dev @tauri-apps/cli
In package.json
, add the following in "scripts":
{
//...,
"scripts": {
// ...,
"tauri": "tauri"
}
// ...
}
Scaffold the Tauri app:
npm run tauri init
For web assets
enter ../build
For URL of dev server
enter http://localhost:5173
(same as Vite)
For frontend dev command
, use npm run make
(or the appropriate command for you package manager)
For frontend build command
, enter npm run build
(same as above, adapt if necessary)
Now you should be ready to develop your app and launch it in dev mode using:
npm run tauri dev
Check [https://tauri.app/v1/guides/] if you run into any issues.
To create a production version of your app:
npm run tauri build
Check [https://tauri.app/v1/guides/building] for more information.