Next.js-重新導向(router) 9月 4 2022 Next 很熟悉的東西。 簡述Next 中也有提供 router 的功能,非常有 React 的味道: 1234567891011121314151617181920212223242526import Link from 'next/link'import { useRouter } from 'next/router'import React, { useEffect } from 'react'export default function NotFound() { const router = useRouter() useEffect(() => { setTimeout(() => { router.push('/') }, 2000) }, []) return ( <div className='not-found'> <h1>Ooops...</h1> <h2>That page cannot be found :(</h2> <p> Go back to the{' '} <Link href='/'> <a>Homepage</a> </Link> </p> </div> )} Next.js-Router Hooks Next.js-404 頁面