Masonite Inertia
4.X
4.X
  • Introduction
  • Installation
  • Demo app
  • The basics
    • Routing
    • Responses
    • Redirects
    • Validation
    • Shared data
    • File uploads
  • Advanced
    • Configuration
    • Root view
    • Partial reloads
    • Authorization
    • CSRF protection
    • Error handling
    • Assets versioning
    • Server-side rendering
    • Testing
  • Development
    • Changelog
    • Contribute
    • Support
Powered by GitBook
On this page
  • Global configuration
  • Local configuration

Was this helpful?

  1. Advanced

Root view

Customizing the root view

PreviousConfigurationNextPartial reloads

Last updated 3 years ago

Was this helpful?

By default an inertia response is rendering data in the default app.html view.

Global configuration

You can change the name of the view globally in the configuration file

config/inertia.py
ROOT_VIEW = "inertia_app"

Now every inertia responses is going to render content in inertia_app.html view.

This can also be done through a .

Local configuration

There are situations where you may want to render content in other view but just e.g. for one controller method. We got you covered !

app/http/controllers/HomeController.py
from masonite.controllers import Controller
from masonite.inertia import InertiaResponse


class HomeController(Controller):

    def index(self, view: InertiaResponse):
        """This view will be rendered in 'home.html'."""
        return view.render(
            "Home",
            { "first_name": "Sam" },
            custom_root_view="home"
        )

    def contact(self, view: InertiaResponse):
        """This view will be rendered in 'app.html'."""
        return view.render("Contact")
custom inertia middleware