v2.1.0
A small client/server-side redirect utility for Next.js
Repository
Current version released
4 years ago
Versions
- v3.2.3Latest
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.2
- v3.0.1
- v3.0.0
- v3.0.0-6
- v3.0.0-5
- v3.0.0-4
- v3.0.0-3
- v3.0.0-2
- v3.0.0-1
- v3.0.0-0
- v2.8.0
- v2.7.2
- v2.7.1
- v2.7.0
- v1.1.1
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.1
- v2.5.0
- v1.0.7
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.15
- v2.1.14
- v2.1.13
- v2.1.12
- v2.1.11
- v2.1.10
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- esm
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
Version 2.0.0 released π₯³
major changes for v2:
- Changed of you can use π for better DX
- Fully esm support
- Suppouted Preact in v2 so all next.js project using Preact Next-redirects-preact
How to install
#using yarn
yarn add Next-Redirects
#using npm
npm i Next-Redirects
How to use use
There is one component that can be used from the library , it can be used in two and hald ways
V2.X.X
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" status={auth.logedin} />
-2.5 you can also use it with a fallback link π
<Redirects href="/main" status={auth.logedin} fallback="/login" />
V2.0.x -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 π