title: NextJS, How to route to internal and external page in NextJS?
body: <p>I have a reactjs app with NextJS and need some help with routing</p>
  
  <p><strong>Structure</strong></p>
  
  <p>Pages</p>
  
  <p>-- location.js</p>
  
  <p>-- selectLocation.js</p>
  
  <p><strong>URL</strong>: location?city=Birmingham&amp;state=AL</p>
  
  <p>1: I want to redirect the user to /selectLocation when no argument is pass</p>
  
  <p>2: I want to redirect the user to "www.google.com" -- if the city=augusta</p>
  
  <p>otherwise, just render the page</p>
  
  <p>This is what is working  but I not sure if is the correct method</p>
  
  <p>Can you please let me know.</p>
  
  <pre><code>export default class extends Component {
    static getInitialProps({ query: { city, state } }) {
      return { city: city, state: state };
    }
  
    componentDidMount() { 
      if (!this.props.city) {
         Router.push('INTERNAL URL')
      } else {
          if (this.props.city === "augusta") {
            window.location = 'https://www.google.com'
          }
      }
     }
  
   render() {
       if (!this.props.city ||this.props.city === "augusta"){
         return null
       }else{
          return(
             &lt;div&gt;...&lt;/div&gt;
          )
       }
  
    }
  }
  
  
  </code></pre>