@ResponseView() or @Render() is a decorator that can be used on a controller method (endpoint). This decorator will use the response return by the method and will use the view to create the output.



This example use EJS as engine rendering. To use other engine, see the documentation of the concerned project.

import {ServerSettings, ServerLoader} from "@tsed/common"
const cons = require("consolidate");
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const compress = require('compression');
const methodOverride = require('method-override');
const rootDir = __dirname;

   viewsDir: `${rootDir}/views`,
   mount: {
      '/rest': `${rootDir}/controllers/**/**.js`
   componentsScan: [
class Server extends ServerLoader {

        this.set("views", this.settings.get('viewsDir')); // le repertoire des vues
        this.engine("ejs", cons.ejs);

    async $onMountingMiddlewares()  {
                extended: true

The configuration engine is exactly the same as Express configuration engine.

Use decorator

export class EventCtrl {

    public get(request: Express.Request, response: Express.Response): any {
        return {startDate: new Date(), name: "MyEvent"};

@Render() is an alias of @ResponseView().

Create your template


<h1><%- name %></h1>
    Start: <%- startDate %>