coogleyao / nextjs-redirect

HOC to redirect to any URL in NextJS both in client and server

Home Page:https://pablo.pink

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nextjs-redirect

Redirect to any URL in NextJS both in client and server

Install

npm install nextjs-redirect

Usage

Let's say you want to create a page /donate that redirects the user to paypal.me with a default value for the money. You create the page as you always do in NextJS (pages/donate.js) and then just use this component with the URL you want:

// pages/donate.js
import redirect from 'nextjs-redirect'
export default redirect('https://paypal.me/pablopunk/5')

You can checkout this example live in pablo.pink

License

MIT

Author

me
Pablo Varela

About

HOC to redirect to any URL in NextJS both in client and server

https://pablo.pink


Languages

Language:TypeScript 100.0%