Skip to content

Conversation

@bknoles
Copy link
Collaborator

@bknoles bknoles commented Nov 19, 2025

Inertia.js allows you to define meta tags in your React app, similar to something like Helmet. However, these will not render until the JS code executes. And while some search crawlers can execute JS, most link preview services (such as posting links to social networks) will not.

One solution to this is server side rendering of the React application. InertiaRails supports SSR via a separate Node process. But if you don't want to run a separate process, InertiaRails has an alternative. With a little setup, you can define meta tags that the Inertia renderer will render both in the Rails application layout and on the client.

This is a lighter weight option if you care most about link sharing with your meta tags.

Steps

  1. Notice that we removed the meta tags from application.html.erb and replaced it with inertia_meta_tags.
  2. Look at the set_default_meta_tags method in ApplicationController.
  3. Visit the root page and "view source". You will see the meta tags rendered in the HTML returned from the server.
image 4. Now visit another page and do the same. You will see a page specific meta tag. image 5. Click around the site and notice that the title in your browser tab updates as you navigate.

@bknoles bknoles force-pushed the server-driven-meta-tags branch from 017c8a5 to e505376 Compare November 21, 2025 20:39
@bknoles bknoles force-pushed the server-driven-meta-tags branch from e505376 to 889f272 Compare November 21, 2025 23:03
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