混合 SSG 和 SSR 的 Catchall 路线

Catchall Routes that mix SSG and SSR

所以我正在做一个项目,其中基础 url 迎合了几种不同类型的页面。 大多数这些页面都是静态的,所以我一直在使用 getStaticPathsgetStaticProps 来生成静态页面并为它们提供服务。

有些页面也是动态查询的,我一直在使用一个简单的 [base].js 文件,该文件使用上面的 getStaticPathsgetStaticProps 并在回退时生成一个 SWR查询以获取数据并在客户端呈现。

所以基本思路是

我想知道是否有一种方法可以在此组合中使用 getServerSideProps,以便我的动态查询可以在服务器端呈现,然后 SWR 只能用于增量目的。

现在,当我将 getServerSideProps 添加到同一个基本文件时,我最终得到 You can not use getStaticProps or getStaticPaths with getServerSideProps. To use SSG, please remove getServerSideProps

next 不能同时使用 SSG 和 SWR,还是有解决方法?

用 Next.js 最接近的是 Incremental Static Regeneration

get the benefits of static (always fast, always online, globally replicated), but with excellent support for dynamic data

不确定是否完全符合您的要求。