编程

Inertia.js 服务端渲染(Server-side Rendering)

1747 2022-01-12 09:28:31

Intertia 团队发布了 Inertia.js 服务端渲染:

? It's finally here. Server-side Rendering for Inertia.js!https://t.co/aaj7umnA12

As always, this means there's a ton of new releases:
✨ server@0.1.0
✅ inertia@0.11.0
✅ inertia-vue@0.8.0
✅ inertia-vue3@0.6.0
✅ inertia-react@0.8.0
✅ inertia-laravel@0.5.1 pic.twitter.com/Jbf8OO4uwr

— Inertia.js (@inertiajs) January 7, 2022

以Laravel或Rails编写的 Intertia.js 应用,已经添加了服务端初始化页面加载的预渲染功能。 SSR使用户与页面的交互更快,使搜索引擎爬取页面更快。

此项工作最为显著的是,SSR意味着你的服务端是使用Node.js编写的,无疑有一部分是使用PHP或者Ruby编写,但是在底层Inertia.js通过独立的Node.js进程渲染HTML:

When Inertia detects that it's running in a Node.js environment, it will automatically render the provided page object to HTML and return it.

However, because most Inertia applications are built in languages such as PHP or Ruby, we'll need to hand the request over to a separate Node.js service so that it can render the page for us and return the generated HTML to the browser when it's done.

更多信息浏览https://inertiajs.com/server-side-rendering