Getting Started with Meteor & React: Part 1

Meteor with React | Image Source

I will start from the introduction of Meteor, Meteor is full-stack JavaScript platform for developing modern web and mobile applications.

  1. Meteor provides you the way to manage Client & Server communication efficiently.

  2. It is built upon Node.js & MongoDB.

  3. It includes a key set of technologies for creating a Full stack Web-app, using build tool and curated set of Node.js packages.

    It’s not just a framework, it’s more than that. You can think of Meteor to Node.js as Rails to Ruby.

While React is front end library developed by Facebook. It’s used for handling view layer for web and mobile apps. ReactJS allows us to create reusable UI components. It is currently one of the most popular JavaScript libraries and it has strong foundation and large community behind it.

In this article, we’ll be making a Todo App and our main focus will be on Meteor and its derivatives. So I will not be covering more of React.js in this post. If you want to learn more about React, you can go to its Official docs.

Prerequisites

  1. Node.js

  2. A Text Editor ( For me, it’s VS Code )

Project Structure:

├── client
│ ├── main.css
│ ├── main.html
│ └── main.jsx
├── imports
│ ├── api
│ │ ├── tasks.js
│ │ └── tasks.test.js
│ ├── startup
│ │ └── accounts-config.js
│ └── ui
│ ├── AccountsUIWrapper.jsx
│ ├── App.jsx
│ └── Task.jsx
├── package.json
└── server
 └── main.js

Let’s Start:

Here, I will be making the Todo App from the Official tutorials which will manage a ‘todo list’ on which registered users can collaborate with others on those task.

If you haven’t already Installed Meteor, Please install it using the methods provided by Meteor. This Project has been built using Meteor version 1.5.

Now as the next step, to create a Meteor app, Open the terminal and type:

meteor create simple-todos

After running this in terminal, You’ll have a new folder called simple-todos with all of the files that a Meteor app needs.

**client/main.js**      *# a JavaScript entry point loaded on the client*

**client/main.html **   *# an HTML file that defines view templates*

**client/main.css**     *# a CSS file to define your app's styles*

**server/main.js**      *# a JavaScript entry point loaded on the server*

**package.json **       *# a control file for installing NPM packages*

**.meteor **            *# internal Meteor files*

**.gitignore **         *# a control file for git*

To get your app running, type in terminal:

cd simple-todos
meteor

Now open ***http://localhost:3000 ***in your web browser to see the app running.

At the very initial Phase, it’ll look like the image below :

Now that the app is working in your browser, let’s start building our Todo-list app.

Using React components to declare the Views:

To start working with React as our Front end library, we’ll have to import some npm packages provided. Open the terminal in the App directory and type:

meteor npm install — save react react-dom

To learn about meteor npm , go to the official docs.

From here, we’ll be using our own codebase by replacing the default code provided bye the Meteor boilerplate.

Let’s replace the starter html code with this one:

<!-- ***client/main.html -->***

<head>

  <title>Todo List</title>

</head>

<body>

  <div id="render-target"></div>

</body>

Meteor parses all of the HTML files in your app folder and identifies three top-level tags: , , and