Toastr
~10 mins
- nextjs
Toastr
Task 1 : Install Toastr
npm install react-hot-toast
Task 2: Include Toastr in Layout
import { Toaster } from "react-hot-toast";
...
<body>
<Toaster/>
{children}
</body>
- Create File -
not-found.tsx
"use client";
import toast from "react-hot-toast";
export default function Home() {
const notify = () => toast.success('Success');
//const notify = () => toast.error('Failure');
return (
<main>
<h3>Welcome to TodoApp</h3>
<button onClick={notify}> Submit</button>
</main>
);
}
Test a invalid url
Note: It should display page not found page.