This is a Tauri v2 GitHub template, which uses SvelteKit as its frontend.
Run
pnpm create tauri-app .
from the project root to update dependencies.
The SvelteKit app bootstrapped by Tauri does not come with ESLint and Prettier. I added them manually. You can update the SvelteKit part separately by running
pnpm create sveltekit@latest .
Follow the instructions in template-sveltekit-example. But you need to review changed files because this command overrides some of the files generated by Tauri.
Tauri generates a SvelteKit app with adapter-static. In combination with Tauri, you cannot use SvelteKit's server-side features. In a Tauri app, anything that SvelteKit would handle server-side, should be handled by Tauri's Rust backend.
The adapter-static generates the index.html
file that Tauri launches inside the webview.
Normally, you use adapter-static with these two settings in /src/routes/+layout.ts
:
prerender = true
: Generate an HTML page for each route. You can enter the application through
each generated page and fromt there the app will be hydrated.ssr = true
: Server-side render all pages at build time. This means that the HTML pages are
rendered at build time. Otherwise they would be empty and rendered client-side.In combination with Tauri, you should set ssr = false
because Tauri requires acccess to window
,
which is not availalbe during SSR. You can set ssr = true
but then you would have to use
client-side checks before using Tauri's API. And you have to make sure that all dependecies are also
server-side renderable.
You can also create a true SPA app by setting prerender = false
in combination with ssr = false
.
But then you need to configure a fallback page index.html
in for the static-adapter.