loading...

Neutralinojs: For lightweight, crossplatform applications

ajeebkp23 profile image Ajeeb.K.P ・2 min read

build-things-with-Neutralinojs (2 Part Series)

1) Neutralinojs: For lightweight, crossplatform applications 2) Neutralinojs: Get started with cli

Introduction

Portable and lightweight cross platform application development framework. Or you may think it like a lightweight Electron.

Getting the Starter Kit

Download Starter Kit (In docs, they call it SDK. I feel it like a Starter kit or Bootstrap) from github releases page https://github.com/neutralinojs/neutralinojs/releases. ie. Download neutralinojs-v1.3.0.zip file.

Now extract it. It contains 2 folders (app:- where we write our UI code in html, js and css, storage: another folder) and 3 executables(1 each for Linux, Windows and Mac).

Code it

As I mentioned above we are going to add UI related logic in html, js and css. Open below files, and replace content as I mentioned.

app/index.html

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

  </body>
</html>

app/assets/app.css

html, body{
    margin: 0px;
    padding: 0px;
}

#neutralinoapp {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #FFD700;
}

#neutralinoapp h1 {
    position: relative;
    float: left;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: Arial;
    font-size: 60px;
    padding: 0px;
    margin: 0px;
}

app/app.js

var getUsername = function () {
    var key = NL_OS == 'Windows' ? 'USERNAME' : 'USER';
    Neutralino.os.getEnvar(key, function(data) {
        document.getElementById('name').innerText = data.value;
    },
    function () {
        //handle error
    }
    );

}

Neutralino.init({
    load: function () {
        getUsername();
    }
});

Run it

Go to the folder, double click the executable corresponds to your OS. Mine was Linux (Debian). So, I opened neutralino-linux. A window was shown with Hello myusername.

Conclusion

Neutralinojs is a very simple and straight forward framework for building apps. In my case, my neutralino app was taking only 11MB of my RAM (I think, it takes around 30MB or 40MB for electronjs.).

Call for action

What do you think about this app ?
Do you find any alternative to this ?
Comment it below.

Reference

https://neutralino.js.org
https://neutralino.js.org/docs/#/gettingstarted/firstapp

build-things-with-Neutralinojs (2 Part Series)

1) Neutralinojs: For lightweight, crossplatform applications 2) Neutralinojs: Get started with cli

Posted on by:

ajeebkp23 profile

Ajeeb.K.P

@ajeebkp23

Muslim, Husband, Programmer, Indian/Kerala. Speaks English, Malayalam. Always curious about technology, computing etc.

Discussion

markdown guide