---
title: "Using Fluid in TYPO3"
manual: "TYPO3 Explained"
version: "13.4"
permalink: "https://docs.typo3.org/permalink/t3coreapi:fluid-usage-in-typo3@13.4"
source: "ApiOverview/Fluid/UsingFluidInTypo3.rst"
rendered: "2026-10-05T17:28:20+00:00"
---

# Using Fluid in TYPO3 {#fluid-usage-in-typo3}

Here are some examples of how Fluid can be used in TYPO3:

-   Create a template (theme) using a combination of TypoScript
    [FLUIDTEMPLATE](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/ContentObjects/Fluidtemplate/Index.html#cobj-fluidtemplate) and Fluid.
    Check out the [TYPO3 site package tutorial](https://docs.typo3.org/m/typo3/tutorial-sitepackage/13.4/en-us/Index.html#start) which walks you through the
    creation of a sitepackage extension.
-   [Create a custom content element type](https://docs.typo3.org/permalink/t3coreapi:adding-your-own-content-elements@13.4) in addition to the already existing
    content elements TYPO3 supplies.
-   [Extbase-based controllers](https://docs.typo3.org/permalink/t3coreapi:extbase-controller@13.4) have a default Fluid
    view in `$this->view`.
-   Use Fluid to create emails using the [TYPO3 Mail API](https://docs.typo3.org/permalink/t3coreapi:mail-fluid-email@13.4).
-   Use Fluid in [backend modules](https://docs.typo3.org/permalink/t3coreapi:backend-modules-template@13.4), either with or
    without Extbase.
-   Use the [generic view factory](https://docs.typo3.org/permalink/t3coreapi:generic-view-factory@13.4) to create a
    Fluid view.

<!-- TODO: no Markdown rendering for "deprecated" -->

These classes have been marked as deprecated in TYPO3 v13 and will be removed in v14:\TYPO3\CMS\Fluid\View\StandaloneView\TYPO3\CMS\Fluid\View\TemplateView\TYPO3\CMS\Fluid\View\AbstractTemplateView\TYPO3\CMS\Extbase\Mvc\View\ViewResolverInterface\TYPO3\CMS\Extbase\Mvc\View\GenericViewResolver

## Using the generic view factory (ViewFactoryInterface) {#generic-view-factory}

<!-- TODO: no Markdown rendering for "versionadded" -->

Class \TYPO3\CMS\Core\View\ViewFactoryInterface has been added as a
generic view factory interface to create views that return an instance of
\TYPO3\CMS\Core\View\ViewInterface. This implements the "V" of "MVC"
in a generic way and is used throughout the TYPO3 core.

You can [inject](https://docs.typo3.org/permalink/t3coreapi:dependency-injection@13.4) an instance of the
`\TYPO3\CMS\Core\View\ViewFactoryInterface` to create an instance of a
`\TYPO3\CMS\Core\View\ViewInterface` where you need one.

> [!NOTE]
> [Extbase-based controllers](https://docs.typo3.org/permalink/t3coreapi:extbase-controller@13.4) create a view
> instance based on this factory by default and which is accessible as
> `$this->view`.

**EXT:my_extension/Classes/Controller/MyController.php (Not Extbase)**

```php
<?php

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;

final readonly class MyController
{
  public function __construct(
    private ViewFactoryInterface $viewFactory,
  ) {}

  public function myAction(ServerRequestInterface $request): string
  {
    $viewFactoryData = new ViewFactoryData(
      templateRootPaths: ['EXT:my_extension/Resources/Private/Templates'],
      partialRootPaths: ['EXT:my_extension/Resources/Private/Partials'],
      layoutRootPaths: ['EXT:my_extension/Resources/Private/Layouts'],
      request: $request,
    );
    $view = $this->viewFactory->create($viewFactoryData);
    $view->assign('mykey', 'myValue');
    return $view->render('path/to/template');
  }
}

```

The `\TYPO3\CMS\Core\View\ViewFactoryInterface` needs an instance of
`\TYPO3\CMS\Core\View\ViewFactoryData`, which is a data object and should
therefore be created via `new`.

Best practices in creating a `\TYPO3\CMS\Core\View\ViewFactoryData`
instance:

-   Hand over request of type `\Psr\Http\Message\ServerRequestInterface`
    if possible. See [Getting the PSR-7 request object](https://docs.typo3.org/permalink/t3coreapi:getting-typo3-request-object@13.4).
-   Use the tuple `$templateRootPaths`, `$partialRootPaths` and
    `$layoutRootPaths` if possible by providing an array of "base" paths
    like `'EXT:my_extension/Resources/Private/(Templates|Partials|Layouts)'`
-   Avoid using parameter `$templatePathAndFilename`
-   Call `render('path/within/templateRootPath')` without file-ending on the
    returned ViewInterface instance.
