This week, Ayushi Mansingka from our team at GeekyAnts, spoke about her work with Meteor for a React Native project she was working on.

Before getting into the project’s specifics, let me brief Meteor in a few points:

Meteor is an open-source JavaScript platform used for apps.

It has a full JavaScript stack, allowing us to do great things with less lines of code, which took lot more lines of code to accomplish.

Meteor, which released in December 2011, has since grown popular amongst developers. It is more preferred than Laravel or Ruby on Rails.

Meteor provides access to real time data. This is one area where it is better than other platforms like REST.

Server-Client communication in REST API

Working with Meteor

We were given the task of building a React Native app which would allow a user to buy and sell services. We used Meteor as backend and Redux for storing data related to forms and user input.

The best part of Meteor is that it is easy to install. If you are working on Windows, you can install it from here. Mac and Linux users can install it by opening a terminal and typing curl https://install.meteor.com/ | sh.

With just a few commands, you can get a working app and work on its development instead of wasting time on setup.

There is already a React-Native-Meteor package, which made it easy for us to get React Native and Meteor to talk to each other.

Meteor uses MongoDB but has no strict guidelines for building the backend, so we used the “aldeed: simple-schema” package, also provided by Meteor, to create our own collections and validate the objects.

Meteor’s package repository-Atmosphere has more 5000 packages. This came in handy while we were building our app.

After our data models were ready, we were ready to integrate the UI with the backend. The pub/sub mechanism was helpful in this as it provided us with real-time data.

Connection between server and client using Websockets

Data transfer is done using Websockets, which establishes a long held TCP connection between server and a client. This also allows data to transfer in real-time. The server can also push any changes that occur in the database on to the client.

Meteor also has Optimistic UI updating, which allows an app to give quick response to any user inputs.

The server-client communication is seamless. All we had to do was write queries on the front-end and MongoDB updates the UI on the frontend whenever there is a change at the backend.

Dataflow in Meteor from the database to theUI

Being able to use the same queries at both, server and client’s side further sped up the development process.

Security rules allow only server-side updates and deny all client-side updates. All database operations are needed to be performed using Meteor methods.

Filtering the listings was also made easier by passing the user’s preferred coordinates to publications where we used MongoDB geospatial queries to return data to the subscriptions.

Data synchronisation was also easy and straightforward. We had to subscribe to the data we need at front-end and render it in our UI. All real-time updates were taken care of.

Overall, using Meteor with React Native allowed us to move at a faster pace and helped us create our app in a simpler way. While Meteor is not suitable to use if you want to scale your app, we recommend using it for apps which require data in real time.