简体   繁体   English

如何在 nextjs 上获得服务器端渲染结果?

[英]How can you just get server side rendering result on nextjs?

In a api route of my nextjs server, I want to request the server itself for a page where it will perform validation and return the result(whether it's validate or not), and I'll do next step depending on the result.在我的 nextjs 服务器的api 路由中,我想向服务器本身请求一个页面,它将执行验证并返回结果(无论是否验证),我将根据结果执行下一步。

I need this flow because I want to use same validation codes on both client side and server side, and the codes depend on hooks(like redux selector).我需要这个流程,因为我想在客户端和服务器端使用相同的验证代码,并且代码取决于钩子(如 redux 选择器)。

Is it possible?可能吗? Or is there any work around to meet what I intend to do?或者有什么办法可以满足我打算做的事情吗? I hope there is at least a way to redirect in component during server side rendering as workaround.我希望至少有一种方法可以在服务器端渲染期间重定向组件作为解决方法。

If it's possible, would there be a way for a nextjs to return just a simple text message as the page result?如果可能的话,nextjs 是否有办法只返回一条简单的文本消息作为页面结果? So I can easily see if validation has gone ok.所以我可以很容易地看到验证是否正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NextJS 服务端渲染 - NextJS server side rendering 在Nextjs中,如何以编程方式触发服务器端渲染? - In Nextjs, how to programatically trigger server side rendering? 我可以将 UseState 与服务器端渲染一起使用吗? Nextjs/JavaScript - Can I use UseState with Server-Side-Rendering? Nextjs/JavaScript 如果你有 apollo react 钩子从后端获取数据,你如何使用 nextjs 进行服务器端渲染? - How do you do server side rendering with nextjs if you have apollo react hooks to fetch data from backend? Nextjs 不在服务器端渲染中渲染 CSS - Nextjs is not rendering CSS in Server Side Rendering 如何处理 Nextjs 中的服务器端渲染错误? - How do I handle server side rendering error in Nextjs? 如何在 nextjs 中实现与服务器端渲染反应的错误边界? - How to implement error boundary in react with server side rendering in nextjs? 服务器端渲染的 Nextjs Bootstrap Dropdown 问题 - Nextjs Bootstrap Dropdown issue with server side rendering 如何在 nextjs 中集成 FCM。 我们可以在 nextjs 服务器端管理 fcm 的服务器端事件吗? - How to Integrate FCM in nextjs. Can we manage the server side events of the fcm in nextjs server side? 你如何在无头 wordpress 中使用 nextjs [id].js 进行服务器端渲染? 使用 graphql 从 Wordpress 获取单个页面。比如 service/[id].js - How do you do server side rendering with nextjs [id].js in headless wordpress? fetch single page using graphql from Wordpress. like service/[id].js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM