Custom Not Found & Loading Pages
Custom Not Found & Loading Pages
1. Create a Custom Not Found Page
a. Create the File in the App Folder
b. Build the React Component
export default function NotFound() { return ( <div> {/* Custom Not Found content will go here */} </div> ); }
jsxCopyimport { FaExclamationTriangle } from 'react-icons/fa';<FaExclamationTriangle className="fa-5x text-8xl text-yellow-400" />
import Link from 'next/link';<Link href="/"> <a className="bg-blue-700 hover:bg-blue-800 text-white font-bold py-4 px-6 rounded"> Go Home </a> </Link>
//app/not-found.jsx import Link from 'next/link'; import { FaExclamationTriangle } from 'react-icons/fa'; export default function NotFoundPage() { return ( <section className="bg-blue-50 min-h-screen flex-grow"> <div className="container m-auto max-w-2xl py-24"> <div className="bg-white px-6 py-24 mb-4 shadow-md rounded-md border m-4 md:m-0"> <div className="flex justify-center"> <FaExclamationTriangle className="fa-5x text-8xl text-yellow-400" /> </div> <div className="text-center"> <h1 className="text-3xl font-bold mt-8 mb-2">Page Not Found</h1> <p className="text-gray-500 text-xl m-10"> The page you are looking for does not exist. </p> <Link href="/" className="bg-blue-700 hover:bg-blue-800 text-white font-bold py-4 px-6 rounded"> Go Home </Link> </div> </div> </div> <div className="flex-grow"></div> </section> ); }
2. Create a Custom Loading Page
a. Create the File in the App Folder
b. Build the React Component
3. Testing and Verification
a. Run the Application
b. Test the Custom Pages
Recap
Last updated