Creating A Simple Profile Application WithÂ MoonJS
Tags: moonjs, javascript, html5css, web
Published: 2017-08-06 18:09:01

---
title: Creating A Simple Profile Application WithÂ MoonJS
published: true
description: A Basic Tutorial on MoonJs teaching installation and basics
tags: moonjs,Javascript,html5-css,web
---

Hello! MoonJs is a relatively new Javascript framework that I saw there was no tutorial on and I decided to try it then write a basic tutorial on it. So,just as we have Preact for ReactJs, we have “Moon” for VueJs. Some of the key things about MoonJs is that like some other javascript frameworks, it is very light. Moon uses a fast Virtual DOM, and can re-render the DOM efficiently and most importantly, MoonJs is so easy to learn.Â 
I will be building a simple application that shows the basic information about a user and this tutorial is to give an head start to using MoonJs.

## Requirements
* Knowledge of JavaScript
* Text Editor

## Installation
To install MoonJs, there are two ways. One way is through [Moon-cli](https://github.com/KingPixil/moon-cli) and the other way is through Content Delivery Network (CDN) which can be found [here](http://moonjs.ga/docs/installation.html). To setup our project well, run the following commands below:
```
mkdir moon-tutorial
cd moon-tutorial
```
The following command will create a new folder called moon-tutorial and check into the directory. So after doing that, open your project in your favourite text editor then create a file called app.html then add the lines of codeÂ 
```
<!DOCTYPE html>
<html>
<head>
 <title>Moon Tutorial</title>
 <meta charset="UTF-8">
 <!-- Development Build -->
 <script src="https://unpkg.com/moonjs/dist/moon.js"></script>
</head>
<body>
</body>
</html>
```
## Adding MoonJs Flavour
Create a folder called src and create another folder inside it called js then create a file called app.js in the the folder. In the file, we will be initiating an instance of MoonJs to display “Hello Pusher of Codes”. We will achieve this by adding the following codes below to the app.js file.
```
const moon = new Moon({
  el: ".app",
  data: {
    message: "Hello Pusher of Codes!"
  }
});
```
Update your app.html to look like this:
```
<!DOCTYPE html>
<html>
<head>
 <title>Moon Tutorial</title>
 <meta charset="UTF-8">
 <!-- Development Build -->
 <script src="https://unpkg.com/moonjs/dist/moon.js"></script>
</head>
<body>
<div class="app">
  <h1 style="text-align:center;">{{message}}</h1>
</div>
<script src="src/js/app.js"></script>
</body>
</html>
```
With the above you should see something like this below:

![](https://cdn.scotch.io/32839/WLyTjSu6TvKKXTF8GlOb_m1.png)




## Building A Simple Profile
Let us make our application look  better with more information about the user. Add the code below to app.html file:
```
<!DOCTYPE html>
<html>
<head>
 <title>Moon Tutorial</title>
 <meta charset="UTF-8">
 <!-- Development Build -->
 <script src="https://unpkg.com/moonjs/dist/moon.js"></script>
</head>
<body>
<div class="app">
  <h1 id="name">{{full_name}}</h1>
  <p id="email">{{email}}</p>
  <p id="phone">{{mobile_number}}</p>
  <p id="description">{{short_info}}</p>
</div>
<style type="text/css">
 .app{
  margin-top:200px;
 }
#name{
  text-align:center;
  color: blue;
 }
#email{
  text-align:center;
  color: blue;
 }
#phone{
  text-align:center;
  color: blue;
 }
#description{
  text-align:center;
  color: blue;
 }
</style>
<script src="src/js/app.js"></script>
</body>
</html>
```
Then, make changes to the app.js file with the code below
```
const moon = new Moon({
  el: ".app",
  data: {
    full_name: "Goodness Kayode | Pusher of Codes!",
    email:"gtkbrain@gmail.com",
    mobile_number:"+2341188469520",
    short_info:"I am Goodness Kayode also called Pusher of Codes. Linguist turned engineer.Community lover"
  }
});
```
Yupp!!! With this you should have an head start to creating applications with MoonJs.
![](https://cdn.scotch.io/32839/l5P0COCRD6cTJfZ4GxQ8_m2.png)



## Conclusion
I hope you enjoyed the tutorial? I just scratched the surface of the framework but this tutorial will help with teaching you how to setup a MoonJs application and how to write a basic application with the framework.
Link to repository is [here](https://github.com/goodnesskay/moonjs-app)