ArangoDB Foxx


Foxx and single page applications

ArangoDB Foxx can serve as a lean application server in any single page application. Create your single page app using the database, JavaScript, HTML, CSS and images, store everything in ArangoDB’s apps directory and voilà–you are done. It’s simple, rapid and all JavaScript.

Foxx and classic web applications

In a classic web application the frontend is rendered by the backend, may it be Rails, Spring, Django, Symfony or whatever your favorite web stack is. With Foxx you can create your own API on top of the database layer for a couple of good reasons:

  • Reduce the number of requests between database and backend
  • Share application and library code between the Foxx backend and your frontend (remember: it’s just JavaScript)
  • Improve the app performance by executing data-intensive operations directly in the database
  • Write a clean backend code that is organized and easy to understand
  • Reuse your API easily, e.g. from an Android/iOS app
  • Keep your data consistent by executing server-side transactions wrapped in a Foxx method

How does it work?

The Foxx app is a bundle of JavaScript files, images, HTML and CSS files. The bundle is saved in a special directory on the same server as ArangoDB. You can either access the Foxx app directly from the browser or through your backend, e.g. a Rails application. The public methods of your Foxx app are accessible through URLs like

And yes, this is secure and will not expose your database layer unprotected to the world.

Syntax example

The snippet below returns the sum of all entries for a given year in an ArangoDB collection as JSON (think of collections as tables in relational databases).

controller.get("/revenue/:year", function (req, res) {
  var query = "RETURN SUM((FOR bill IN billcollection FILTER bill.year == @year RETURN bill.amount))";
  var stmt = db._createStatement({ "query": query});
  var c = stmt.execute();

Getting started

Foxx is part of ArangoDB and so is the Foxx documentation. So first get your copy of ArangoDB 1.4 or newer. An easy-to-follow tutorial is included in the Foxx documentation.

Other resources

This is a talk Lucas gave at the JavaScript user group in Munich:

Sample apps

Foxx comes with a couple of sample apps. You can install them via “foxx manager” or get a copy directly from Github from


foxx-authentication is a demo app how to restrict the access to certain routes


hello-foxx has basic syntax examples, e.g. on routes, database access, logging, and debugging


aye-aye is an implementation of the famous todo app using Foxx, ArangoDB, and Backbone


fugu is an error logger using Backbone, Jquery, Twitter Bootstrap and Underscore. fugu can be used to log JavaScript errors from any JavaScript driven website/application in ArangoDB.