I made this a template such that I dont have to repeat the process of setting this starting application up everytime I start a new project.
It includes
Take from Wails official page: https://wails.io/docs/guides/sveltekit
Server files will cause build failures.
+layout.server.ts, +page.server.ts, +server.ts or any file with "server" in the name will fail to build as all routes are prerendered.The Wails runtime unloads with full page navigations!
window.location.href = '/<some>/<page>' or Context menu reload when using wails dev. What this means is that you can end up losing the ability to call any runtime breaking the app. There are two ways to work around this.import { goto } from '$app/navigation' then call goto('/<some>/<page>') in your +page.svelte. This will prevent a full page navigation.<head> of myapp/frontend/src/app.html<head>
...
<meta name="wails-options" content="noautoinject" />
<script src="/wails/ipc.js"></script>
<script src="/wails/runtime.js"></script>
...
</head>
See https://wails.io/docs/guides/frontend for more information.
Initial data can be loaded and refreshed from +page.ts/+page.js to +page.svelte.
+page.ts/+page.js works well with load() https://kit.svelte.dev/docs/load#page-data
invalidateAll() in +page.svelte will call load() from +page.ts/+page.js https://kit.svelte.dev/docs/load#rerunning-load-functions-manual-invalidation.
Error Handling
import { WindowReloadApp } from "$lib/wailsjs/runtime/runtime";
export async function handleError() {
WindowReloadApp();
}
Using Forms and handling functions
<form method="POST" on:submit|preventDefault={handle}><form method="POST" use:enhance={({cancel, formData, formElement, submitter}) => {
cancel()
console.log(Object.fromEntries(formData))
console.log(formElement)
console.log(submitter)
handle()
}}>