NUXT3:SSR直接导航,客户端在应用内导航上获取

发布于 2025-02-09 02:43:15 字数 418 浏览 1 评论 0原文

因此,我们有一个带有页面/thick的NUXT3应用程序,该应用程序使用endpoint /api/thing的数据渲染内容,但也用于生成动态元数据在SSR期间(用于SEO和社交卡)。

现在,pages/thing.vue use usefetch在SSR期间获取数据(良好或动态元数据,对UX不利,因为阻止了导航)。

理想情况下,我们将使用usefetch如果客户端直接导航到/thing(例如,通过在其浏览器中键入并按ENTER),但请使用非nvigation-阻止uselazyfetch并在客户端在我们的应用中导航时在前端显示加载页面。

如何实现?

So we have a Nuxt3 application with a page /thing which uses data from endpoint /api/thing to render content but also for generating dynamic metadata during SSR (for SEO and social cards).

Now, pages/thing.vue uses useFetch which fetches the data during SSR (good or dynamic metadata, bad for UX since blocks navigation).

Ideally, we'd have it use useFetch if the client is navigating to /thing directly (e.g. by typing it in their browser and pressing enter) but use non-navigation-blocking useLazyFetch and show a loading page on the front-end when the client is navigating within our app.

How can that be achieved?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文