<SignUp />
component
The <SignUp />
component renders a UI for signing up users. The functionality of the <SignUp />
component are controlled by the instance settings you specify in your Clerk Dashboard(opens in a new tab), such as sign-up options and social connections. You can further customize your <SignUp />
component by passing additional properties at the time of rendering.
The following methods available on an instance of the Clerk
class are used to render and control the <SignUp />
component:
mountSignUp()
Render the <SignUp />
component to an HTML <div>
element.
function mountSignUp(node: HTMLDivElement, props?: SignUpProps): void;
mountSignUp()
params
Name | Type | Description |
---|---|---|
node | HTMLDivElement (opens in a new tab) | The <div> element used to render in the <SignUp /> component |
props? | SignUpProps | The properties to pass to the <SignUp /> component. |
SignUpProps
The type of the props
parameter in the mountSignUp()
function is defined as follows:
Name | Type | Description |
---|---|---|
routing | 'hash' | 'path' | 'virtual' | The routing strategy for your pages. Note: If you are using environment variables for Next.js or Remix to specify your routes, this will be set to path . |
path | string | The path where the component is mounted on when path-based routing is used./sign-in This prop is ignored in hash- and virtual-based routing. |
redirectUrl | string | Full URL or path to navigate after successful sign in or sign up. The same as setting afterSignInUrl and afterSignUpUrl to the same value. |
afterSignInUrl | string | The full URL or path to navigate after a successful sign in. Defaults to / . |
signInUrl | string | Full URL or path to the sign in page. Use this property to provide the target of the 'Sign In' link that's rendered. |
afterSignUpUrl | string | The full URL or path to navigate after a successful sign up. Defaults to / . |
initialValues | SignUpInitialValues | The values used to prefill the sign-up fields with. |
mountSignUp()
usage
index.tsimport Clerk from '@clerk/clerk-js'; // Initialize Clerk with your Clerk publishable key const clerk = new Clerk('{{pub_key}}'); await clerk.load(); document.getElementById("app").innerHTML = ` <div id="sign-up"></div> `; const signUpDiv = document.getElementById("sign-up"); clerk.mountSignUp(signUpDiv);
index.js<!-- Add a <div id="sign-up"> element to your HTML --> <div id="sign-up"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const signUpDiv = document.getElementById('sign-up'); Clerk.mountSignUp(signUpDiv); }); </script>
unmountSignUp()
Unmount and run cleanup on an existing <SignUp />
component instance.
function unmountSignUp(node: HTMLDivElement): void;
unmountSignUp()
params
Name | Type | Description |
---|---|---|
node | HTMLDivElement (opens in a new tab) | The container <div> element with a rendered <SignUp /> component instance |
unmountSignUp()
usage
index.tsimport Clerk from '@clerk/clerk-js'; // Initialize Clerk with your Clerk publishable key const clerk = new Clerk('{{pub_key}}'); await clerk.load(); document.getElementById("app").innerHTML = ` <div id="sign-up"></div> `; const signUpDiv = document.getElementById("sign-up"); clerk.mountSignUp(signUpDiv); // ... clerk.unmountSignUp(signUpDiv);
index.js<!-- Add a <div id="sign-up"> element to your HTML --> <div id="sign-up"></div> <script> window.addEventListener("load", async function () { await Clerk.load(); const signUpDiv = document.getElementById('sign-up'); Clerk.mountSignUp(signUpDiv); // ... Clerk.unmountSignUp(signUpDiv); }); </script>
openSignUp()
Opens the <SignUp />
component as an overlay at the root of your HTML body
element.
function openSignUp(props?: SignUpProps): void;
openSignUp()
params
Name | Type | Description |
---|---|---|
props? | SignUpProps | The properties to pass to the <SignUp /> component |
openSignUp()
usage
index.tsimport Clerk from '@clerk/clerk-js'; // Initialize Clerk with your Clerk publishable key const clerk = new Clerk('{{pub_key}}'); await clerk.load(); clerk.openSignUp();
index.html<script> window.addEventListener("load", async function () { await Clerk.load(); Clerk.openSignUp(); }); </script>
closeSignUp()
Closes the sign up overlay.
function closeSignUp(): void;
closeSignUp()
usage
index.tsimport Clerk from '@clerk/clerk-js'; // Initialize Clerk with your Clerk publishable key const clerk = new Clerk('{{pub_key}}'); await clerk.load(); clerk.openSignUp(); // ... clerk.closeSignUp();
index.html<script> window.addEventListener("load", async function () { await Clerk.load(); Clerk.openSignUp(); // ... Clerk.closeSignUp(); }); </script>