Lenra Docs
Register on Lenra
  • Home
  • Getting started
  • Guides
  • Features
  • References
  • Contribute



    Our framework is based on four parts: data, views, listeners, and users.

    Lenra uses a simple but efficient realtime MVC pattern. This means that any data changes will update the view in real time for every connected users.


    The data in Lenra is simply a mongo database. In this database you will store documents that are basically JSON objects. Those JSON objects will be stored in collections. For example, create a ingredients collection that will store all the ingredients of your cooking app. Then create a recipes collection to store your recipes…

    You can also query into your documents using the mongo query language.


    The views are simple functions with optional arguments:

    This function will return a JSON tree. If one of the two argument changes, the view is rebuilt.

    There is two kind of views in Lenra apps:


    We have integrated the users management in our framework since the apps are made for them. So we handle account management, authentication, authorization, and user data for you.

    The users will have a single Lenra account that will be used for all the apps they use, but we a specific ID for each app. This system make it simpler for you to handle user data and give the users the a protection over there personnals data.

    To link a data to the current user, just use the @me string as the user ID in your data and queries, and it will be replaced by the unique user ID of the current user for your app.


    The listeners are event based workflows and are the only way to change the data. A listener is a function that is able to call the data API to get/create/update/delete documents. They are called when an action is performed by the user on the UI (button pressed, click, checkbox checked…) or by external events (CRON, WebHooks…).

    A listener takes 3 arguments: a property object (props), the event that triggered this listener and an api object that contains all the informations needed to call the API.

    To update the model, simply call the HTTP data API in your listener.