Building realtime apps with Horizon and RethinkDB without writing server side/backend code

Horizon is a realtime and open source JavaScript backend which allows you to build realtime mobile and desktop web applications without actually writing any server side code so if you are a fronend mobile or web developer ,you don't have experience with server side frameworks and technologies and you don't want to hire a backend developer you take advantage of Horizon to build a backend for your web or mobile app .

Horizon is built by the team behind RethinkDB and contributions from an open source community .

Horizon has all features needed by a modern and realtime web or mobile application such as

Modularity and extensibility :

You can have a full and ready backend with an API for your apps .You just need to focus on the frontend of your app and then plug in your app to Horizon backend in no time .Horizon is also very extensible so if your app grows up to a level where it needs custom code you can easily write backend code and extend your app capability without rewriting your app from scratch .

Horizon has powerful realtime features

Since horizon is built on top of RethinkDB which a realtime database built by the same team behind Horizon ,you have powerful realtime features backed in your app with no extra code .RethinkDB has a powerful builtin query language and can push realtime data updates to your app users without writing extra code or sacrificing performance .

Built in Auth and permissions system

Horizon has an API for authenticating users with common providers such as Facebook ,GitHub or Google and a permission system for protecting data from unauthorized access .

How to get started with Horizon ?

So the first thing you need to do is to install Horizon or precisly the Horizon CLI (Command Line Interface) via NPM .So go ahead and open up your terminal then type the following

npm install -g horizon

Next cd into your working directory

cd into-working-directory

And scaffold a new Horizon app with hz CLI

hz init my-horizon-app

You can also create your app folder by yourself ,navigate to it and then execute without folder name to use the current folder as your app root folder .

hz init

hz init will copy a bunch of files and create a directory structure for your app which looks like

The dist folder contains static files and it is used as an output folder for a build system of your choice .

The src folder is the input folder for your build system if you choose to use a build system .

You can also directly create files inside dist folder which can be then served .

Now lets serve our app

hz serve --dev

If you haven't installed RethinkDB you are going to get an error message

`rethinkdb` not found in $PATH, please install RethinkDB.    

So you need to install RethinkDB by following this tutoriat .

After installing RethinkDB serve your app again .If you get

Horizon ready for connections

Then congratulations your app is served .Go to http://localhost:8181

You should see “App works!” message .


So congratulation ,you have created your first realtime app with Horizon .This is a tutorial for introducing Horizon and show you how you can start building realtime apps without writing any backend code .In next tutorials we are going to see how to build fully fledged realtime app with Horizon and RethinkDB .

Note: We also publish our tutorials on Medium and If you prefer reading in these platforms, you can follow us there to get our newest articles.

You can reach the author via Twitter:

About the author

Ahmed Bouchefra
is a web developer with 5+ years of experience and technical author with an engineering degree on software development. You can hire him with a click on the link above or contact him via his LinkedIn account. He authored technical content for the industry-leading websites such as SitePoint, Smashing, DigitalOcean, RealPython, freeCodeCamp, JScrambler, Pusher, and Auth0. He also co-authored various books about modern web development that you can find from Amazon or Leanpub

Get our Learn Angular 8 in 15 Easy Steps ebook in pdf, epub and mobi formats, plus a new Angular 8 tutorial every 3 days.

comments powered by Disqus Protection Status