Skip to content

ciscoheat/neutralinojs-sveltekit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

neutralinojs-sveltekit

Create SvelteKit cross-platform desktop apps with ease using Neutralinojs and this template.

Project setup

Install Node.js and Neutralinojs first, then execute the following commands:

Note that MYAPP should be changed to your app name, but app in the SvelteKit creation script should not be changed. Also note that the SvelteKit project should be using Typescript, and that it will be a Single-page app, so no server.ts modules can be used, you will use the Neutralinojs API for "server"/native access instead. Finally you don't need to install a specific SvelteKit adapter, it will be taken care of later.

neu create MYAPP --template ciscoheat/neutralinojs-sveltekit
cd MYAPP
neu update
npx sv create app
node postinstall.mjs
cd app && npm install -D vite-plugin-neutralino @sveltejs/adapter-static @neutralinojs/lib && cd ..

The node postinstall.mjs command patches the SvelteKit installation and adds a few files, so it works with Neutralinojs. Check its source if you want to know what it does.

Test if it works with neu run. (Sometimes, starting the app the very first time doesn't work, then start it again a few times.)

To test the Native API, add "filesystem.readDirectory" to nativeAllowList in neutralino.config.json, then add these two files:

app/src/routes/+page.ts

import { filesystem } from "@neutralinojs/lib";

export const load = async () => {
  const files = await filesystem.readDirectory(".");
  return { files };
};

app/src/routes/+page.svelte

<script lang="ts">
	import type { PageProps } from './$types';
	let { data }: PageProps = $props();
</script>

<h1>Files</h1>

<ul>
	{#each data.files as file (file.path)}
		<li>{file.entry} {file.path} {file.type}</li>
	{/each}
</ul>

<style>
	h1 {
		font-size: 150%;
	}
</style>

Please open an issue if something isn't working, or you have some ideas for improvements!

About

SvelteKit cross-platform native desktop development with Neutralinojs

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 94.3%
  • TypeScript 5.7%