Use of presenters in Adonis 4



Please, can someone show me an example of using presenters in Adonis 4.

How the view in controllers can locate the presenters’ folder ?

Thank you…


Create presenters folder inside resources folder.
A basic presenter looks like this:

'use strict'

const { BasePresenter } = require('edge.js')

class Index extends BasePresenter {

  get posts () {
    const posts = this.$data.posts
    // do something with the posts
    return posts


module.exports = Index

Then you can chain presenter before your view.render('index'), kinda like this: view.presenter('index').render('index')

If you want to know more take a look at the video here:


Thank you @keeross !