⛔️ Please upgrade to V 2.0.0 and above ⛔️
major changes for v2 instead of you can use 😆 for better DX
Suppouted Preact in v2 so all next.js project can work with to install it
#using yarn yarn add Next-Redirects-preact #using npm npm i Next-Redirects-preact
for normal react/next.js projects download it via
#using yarn
yarn add Next-Redirects
#using npm
npm i Next-Redirects
Next-Redirects
Next-Redirects is a small Redirect utility component for Next.js that has the ability to give fallback links for different conditions and with a small package size
How to use Next-redirects
There is one component that can be used from the library , it can be used in two and hald ways
-1 If you have a switch or more than condition
if (user.logedin) {
<Redirects href="/Dashboard" />;
}
switch (condistionX) {
case admin:
<Redirects href="/Dashboard" />;
break;
case anonymous:
<Redirects href="/Login" />;
break;
default:
<Redirects href="/main" />;
}
-2 Using Next-Redirects component directry
<Redirects href="/main" condition={auth.logedin} />
-2.5 you can also use it with a fallback link 😆
<Redirects href="/main" condition={auth.logedin} fallback="/login" />
this is just and example you can use it for whatever usecases you can imagine 🛠