Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
@inertia
directive's purpose is to render either the SSR-rendered page content, or the root Inertia element@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-partyHttpGateway
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.