I am trying to add page transitions to my Nextjs app. What should I do to add that?
I am trying to add page transitions to my Nextjs app. What should I do to add that?
You can install the dependency react-transition-group
$ npm install react-transition-group
create a transition_sample.js or transition_sample.tsxcomponent in the component folder
Next, import the transition_sample.js or transition_sample.tsx component to your layouts/MainLayout or _app.js or _app.tsx if you're doing this in the _app.js/_app.tsx be sure to replace children with <Component {...pageProps} />
Import useRouter from next//router and pass the pathname to location props
All done then use the MainLayout in your pages and to use the layout wrap your pages with MainLayout.