title: Redirect user to its subdomain in ReactJs
body: <p>I am building a react website where I assign a subdomain to the user when they sign up according to the username they enter, let's say their username is <code>john</code>, then the subdomain will be <code>john.mydomain.com</code>.</p>
  <p>I would like to know how to redirect a user to its subdomain after they signup. I have access to the user data immediately after signup, such as username.</p>
  <p>Sign up code:</p>
  <pre><code>export const signup = (formData, history) =&gt; async (dispatch) =&gt; {
    try {
      // sign up the user
      const { data } = await api.signUp(formData);
      dispatch({ type: &quot;AUTH&quot;, data });
      toast.success(&quot;Signed Up successfully&quot;);
      history.push(&quot;/&quot;);
    } catch (error) {
      dispatch({ type: &quot;ERROR&quot;, data: error?.response?.data });
      toast.error(error?.response?.data?.message);
    }
  };
  </code></pre>
  <p>Thank You.</p>