How to use the next/router.query function in next

To help you get started, we’ve selected a few next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wellcometrust / wellcomecollection.org / catalogue / webapp / components / Auth / Auth.js View on Github external
useEffect(() => {
    const token = getLocalStorageJson('auth.token');
    const code = Router.query.code;

    if (token) {
      setAuthState(authStates.loggedIn);
      // TODO: expiry
      // const expires = newUser.exp * 1000;
      // if (expires <= Date.now()) {
      //   setAuthState(authStates.expired);
      // } else {
      //   setAuthState(authStates.loggedIn);
      // }
    } else if (code) {
      setAuthState(authStates.authorising);
    } else {
      setAuthState(authStates.loggedOut);
    }
  }, []);
github este / este / components / core / Auth.js View on Github external
function onSuccess(auth) {
    const { token } = auth;
    if (token == null) return;
    setCookie({ token });
    // TODO: Typed useRouter.
    if (Router.query.redirectUrl) {
      Router.replace(Router.query.redirectUrl);
    } else if (props.redirectUrl) {
      // $FlowFixMe Wrong libdef.
      Router.replace(props.redirectUrl);
    } else {
      // $FlowFixMe Wrong libdef.
      Router.replace({
        pathname: Router.pathname,
        query: Router.query,
      });
    }
  }
github este / este / components / core / Auth.js View on Github external
function onSuccess(auth) {
    const { token } = auth;
    if (token == null) return;
    setCookie({ token });
    // TODO: Typed useRouter.
    if (Router.query.redirectUrl) {
      Router.replace(Router.query.redirectUrl);
    } else if (props.redirectUrl) {
      // $FlowFixMe Wrong libdef.
      Router.replace(props.redirectUrl);
    } else {
      // $FlowFixMe Wrong libdef.
      Router.replace({
        pathname: Router.pathname,
        query: Router.query,
      });
    }
  }
github zapkub / cu-vivid-museum-wiki / src / pages / result.js View on Github external
Router.onRouteChangeComplete = (url: string) => {
			this.setState({
				text: Router.query.text,
				categories: Router.query.categories.split(','),
			});
		};
	}
github conveyal / analysis-ui / lib / containers / modification-editor.js View on Github external
dispatch(deleteModification(m._id)).then(() => {
        const {projectId, regionId} = Router.query
        const {href, as} = routeTo('modifications', {projectId, regionId})
        Router.push(href, as)
      }),
github conveyal / analysis-ui / pages / callback.js View on Github external
.catch(() => {
        Router.push({
          pathname: RouteTo.login,
          query: Router.query
        })
      })
  }, [dispatch])
github BanditDev / pepega / components / Casino / Game.tsx View on Github external
onClick={() =>
                    Router.push(
                      {
                        pathname: Router.route,
                        query: {
                          ...Router.query,
                          authModal: 1
                        }
                      },
                      `/auth?continue=${Router.asPath}`,
                      { shallow: true }
                    )
                  }
github ooni / orchestra / frontend / pages / admin / login.js View on Github external
.then(() => {
        let redirectPath = '/'
        this.setState({
          error: null
        })
        if (Router.query.from) {
          redirectPath = Router.query['from']
        }
        Router.push(redirectPath)
      })
      .catch(err => {
github ooni / orchestra / frontend / pages / admin / login.js View on Github external
.then(() => {
        let redirectPath = '/'
        this.setState({
          error: null
        })
        if (Router.query.from) {
          redirectPath = Router.query['from']
        }
        Router.push(redirectPath)
      })
      .catch(err => {
github jaggerwang / react-in-practice / pages / login.js View on Github external
.then(resp => {
          this.setState({ isSubmitting: false })
          Router.replace(Router.query.from || '/')
        })
    })