{"repo":"pablopunk/nextjs-redirect","free":true,"listed":false,"github":"https://github.com/pablopunk/nextjs-redirect","clone":"git clone https://github.com/pablopunk/nextjs-redirect.git","description":"HOC to redirect to any URL in NextJS both in client and server","language":"JavaScript","stars":143,"topics":["hacktoberfest","nextjs","redirect","hoc","dynamic"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"nextjs-redirect Redirect to any URL in NextJS both in client and server Install 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: You can checkout this example live in pablopunk.com Status code (301, 302...) By default, it will send a 301 status code. This can be customized by an optional parameter: Client side dynamic routes (as) When redirecting on the client side, if the redirected page is dynamic ( pages/user/[userId]/info.js ), the following redirect will trigger a page refresh: In this case you can use the asUrl option to make a smooth transition between pages without any refresh: Static export This package is compatible with next export since version 4.0.0. See PR #4 for more details. Custom UI component (HOC) In case the navigation is happening client-side, you can use this package as a HOC to provide your custom components/styles for the UI: Redirect to URL from parameters Let's say you have a single page called /redirect , and you wanna use it for all kinds of redirects: /redirect?to=https://google.com /redirect?next=https://twitter.com /redirect?url=https://pablopunk.com Pretty cool huh!? You can do this with nextjs-redirect by passing the name of the parameter you want on the url. For the examples above: Related Working with locales routes? Take a look at nextjs-redirect-","default_branch":null,"files":null,"tree":[],"storefront":"/r/pablopunk","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/pablopunk/nextjs-redirect/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}