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
  • Requirements
  • Installation

Was this helpful?

Installation

Requirements

  • a Masonite 4 project

  • a Node.js environment

Installation

Install the latest Inertia server-side adapter in your project

pip install masonite-inertia

masonite-inertia 4.X versions are for Masonite 4. masonite-inertia 3.X versions are for Masonite 3.

Add InertiaProvider to your project

config/providers.py
# ...
from masonite.inertia import InertiaProvider

PROVIDERS = [
    # ...

    # Third Party Providers
    InertiaProvider,
]

Add the Inertia middleware to your project

from masonite.inertia import InertiaMiddleware


class HandleInertiaRequests(InertiaMiddleware):

It's important to put this middleware in your HTTP middleware and EncryptCookies in route middlewares !

config/middleware.py
# ...
http_middleware = [
    #...,
    HandleInertiaRequests,
]
route_middleware = {
    "web": [EncryptCookies, SessionMiddleware,...]
}

Finally you can (optionally) publish the package configuration file to your project if you want to change some configuration parameters:

python craft package:publish inertia

You should now have a configuration file inertia.py in your project configuration folder.

You're ready to start working with Inertia !

PreviousIntroductionNextDemo app

Last updated 3 years ago

Was this helpful?