Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

effector-next-redirect

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effector-next-redirect

_Redirect to any URL in NextJS both on the client and on the server depending on the state of the store_

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Effector Next Redirect

Redirect to any URL in NextJS both on the client and on the server depending on the state of the store

Installation

npm install effector-next-redirect

or yarn

yarn add effector-next-redirect

Example

  1. Redirect to the /login page, depending on the state of the $isAccessDenied store

    // pages/index.jsx
    import React from "react";
    import { withRedirect } from "effector-next-redirect";
    import { createStore } from "effector";
    
    export const $isAccessDenied = createStore(true);
    
    // redirect with setting 302 status code
    const enhance = withRedirect("/login", $isAccessDenied);
    
    export default function HomePage() {
      return (
        <div>
          <h1>HomePage</h1>
        </div>
      );
    }
    
    export default enhance(HomePage);
    
  2. Redirect to the /login page using replace on the client

    // pages/index.jsx
    import React from "react";
    import { withRedirect } from "effector-next-redirect";
    import { createStore } from "effector";
    
    export const $isAccessDenied = createStore(true);
    
    // redirect with setting 301 status code
    const enhance = withRedirect("/login", $isAccessDenied, { code: 301, replace: true });
    
    export default function HomePage() {
      return (
        <div>
          <h1>HomePage</h1>
        </div>
      );
    }
    
    export default enhance(HomePage);
    

Configuration

The withRedirect function expects to receive the settings object as the third argument:

  • asUrl (string, optional) : mask url for the browser
  • code (number, optional) : status code set by the server after redirection
  • replace (boolean, optional) : use Router.replace instead of Router.push in browser

Keywords

FAQs

Package last updated on 02 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc