Skip to content

grace-plugins/grace-inertia

Repository files navigation

Main branch build status Apache 2.0 license Latest version on Maven Central

Grace with Inertia

Grace Plugin for using Grace/Grails app with Inertia.js.

Usage

Add dependency to the build.gradle,

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.graceframework.plugins:inertia:VERSION"
}

Inertia plugin supports controller-specific withFormat() method,

class BookController {

    def list() {
        def books = Book.list()

        withFormat {
            inertia {
                render(inertia: "Book/List", props: [bookList: books])
            }
            json {
                render books as JSON
            }
        }
    }
}

Also, this plugin supports extendsions for Grails Request and Response,

// You can get Inertia request headers from Grails Request

request.inertia.version == request.getHeader('X-Inertia-Version')

// Check Inertia request?
if (request.inertia as boolean) { // or use request.isInertia()
    template = 'book-detail'
}

// You can set Inertia response headers in Grails

response.inertia.location = 'http://localhost:8080/book/1'

Development

Build from source

git clone https://github.com/grace-plugins/grace-inertia.git
cd grace-inertia
./gradlew publishToMavenLocal

Support Version

  • Grace 2022.0.0+
  • Grails 3.0+

Roadmap

1.x

  • Inertia 1.x

License

This plugin is available as open source under the terms of the APACHE LICENSE, VERSION 2.0

Links