Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inertia SSR directives #339

Merged
merged 8 commits into from
Dec 30, 2021
Merged

Add Inertia SSR directives #339

merged 8 commits into from
Dec 30, 2021

Conversation

claudiodekker
Copy link
Member

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.

1 participant