Skip to content

Conversation

@claudiodekker
Copy link
Contributor

This PR both adds an @inertiaHead directive, and updates the @inertia directive, with the intention of making the application-side setup of Server Side Rendering a breeze.

Directives

  • The @inertia directive's purpose is to render either the SSR-rendered page content, or the root Inertia element
  • The new @inertiaHead directive's purpose is to render SSR-rendered 'head' tags. When SSR is disabled or fails, this directive will render nothing.

Gateway Interface

Instead of letting the directives themselves make Http requests to a configurable SSR-renderer service, the directives will delegate this responsibility to a new Gateway interface, which by default is bound to the (also new) first-party HttpGateway class. This allows users to create and use their own SSR-dispatching logic (if needed) by simply swapping out the Gateway implementation within Laravel.

Config Options

Because most users will likely use the default configuration, there are two new configuration options added.

  • ssr.enabled: This option controls whether SSR is enabled or not. When disabled (the default), Inertia will not attempt to make any SSR requests, which will save ~5ms on average per (initial) visit. While SSR-utilizing users will easily gain this time back during client-side rendering, those who don't can use this option to keep pages as fast as they currently are.

  • ssr.url: As you might've already guessed, this option controls the URL that's used when SSR is enabled. While a good default is set, you might the service running on a different host or in a different (networked) container, so that's what this option is for.

@claudiodekker claudiodekker changed the title Prepare Inertia SSR directives Add Inertia SSR directives Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants