We are going to create a simple application using Neutralinojs. This sample application will display Hello with the current username of your operating system. For example, if the current username is John, it will show, Hello John.
You need to install neu CLI to create Neutralinojs applications. However, you can develop applications without CLI as well. But, the CLI will make some hard stuff easy. Run the following command on your terminal to install neu CLI globally.
If you don't want a global installation, use neu CLI with npx.
Enter the following command to scaffold a new app.
The above command will create a new app inside myapp directory. To make sure whether everything is fine, run your application.
If you are on Windows, you might get a blank white screen. The reason for this is, accessing localhost from a UWP context is disabled by default. Run the following command with administrative privileges on the command prompt to fix this.
You may include this in your Windows setup files (with the user's consent) because users also may get an empty white screen on Windows.
For better developer experience, we recommend you to install the WebView2 runtime on Windows.
Insert the following content into your application resource files.
Neutralinojs prevents arbitary native API function execution unlike Node.js environments.
Here we used the
os.getEnv native function, so check whether your application configuration allows
the application frontend to execute it. The default configuration already allows the entire
with the following
nativeAllowList permission setup:
We don't need to update anything in the permission setup since it already allows
os.getEnv native function
As mentioned above, you can use the
run command to start your application.
Congrats! your application works.
neu run command will reload your application when there is a change in application resources.
Try to change your
index.html while the application is running.
To make portable binaries for your application, we can use the
Enter the following command on your terminal to make final binaries for all supported platforms.
The above command will produce binaries for all platforms into the
dist directory and the
--release flag will also package your binaries into a .zip file.
This command will do the work blazing fast because there is no compilation process behind.
Now you know how to create Neutralinojs applications. We will suggest you to look into the following topics next.
Check more details about frontend framework support here.