next.js 我可以为现有的T3堆栈(TypeScript,Tailwind,trpc)制作一个“页面路由器”应用程序到“应用程序路由器”吗?

57hvy0tb  于 12个月前  发布在  TypeScript
关注(0)|答案(1)|浏览(129)

最近我在做一个项目。项目环境已经使用t3堆栈设置好了。但该项目使用的是“页面路由器”。但我想在现有的项目中使用“应用程序路由器”。注意:next.js版本是:13.4.19.我能做吗?如果可以的话,我怎么做呢?
我试图使现有的'页面路由器'项目到'应用程序路由器'

wz3gfoph

wz3gfoph1#

我认为这是可能的。
首先,你需要像这样安装:

npm install next/app next/router

然后更新你的_app.js文件,像这样:

import { useRouter } from 'next/router'; 
import { useEffect } from 'react'; 
import MyApp from 'next/app'; 
function App({ Component, pageProps }) { 
   const router = useRouter(); 
} 
export default App;

相关问题