Skip to main content

Your First Neutralinojs App

Introduction#

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 Shalitha, it will show, Hello Shalitha.

Step 0: Installing neu CLI#

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.

npm install -g @neutralinojs/neu

Step 1: Creating a new app#

Enter the following command to scaffold a new app.

neu create myapp

The above command will create a new app inside myapp directory. To make sure whether everything is fine, Run your application.

cd myapp
neu run
info

If you are on Windows, you might get an empty white screen. The reason is that accessing localhost from a UWP context is disabled by default. Run the following command with administrative privileges on the command prompt. 

CheckNetIsolation.exe LoopbackExempt -a -n="Microsoft.Win32WebViewHost_cw5n1h2txyewy"

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.

Step 2: Writing JavaScript, HTML, and CSS#

Insert the following content into your application resource files.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>NeutralinoJs</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="neutralinoapp">
<h1 id="name"></h1>
</div>
<script src="js/neutralino.js"></script>
<script src="js/main.js"></script>
</body>
</html>

Step 3: Running your application#

As mentioned above, you can use the run command to start your application.

neu run

Congrats! your application works.

mypp is running on Linux

info

For debugging purposes, you can use neu listen command. The listen command will reload your application when there is a change in application resources.

Step 4: Building your application #

To make portable binaries for your application, we can use the build command. Enter the following command on your terminal to make final binaries. 

neu build --release

The above command will produce binaries for all platforms into the dist directory. This command will do the work blazing fast because there is no compilation process behind.

What's next?#

Now you know how to create Neutralinojs applications. We will suggest you to look into the following topics next.