<SignUp />
component
The <SignUp />
component renders a UI for signing up users. The functionality of the <SignUp />
component is controlled by the instance settings you specify in your Clerk Dashboard, such as sign-in and sign-up options and social connections. You can further customize your <SignUp />
component by passing additional properties at the time of rendering.
Properties
All props are optional.
- Name
appearance
- Type
Appearance | undefined
- Description
Optional object to style your components. Will only affect Clerk Components and not Account Portal pages.
- Name
routing
- Type
'hash' | 'path' | 'virtual'
- Description
The routing strategy for your pages.
Note: If you are using environment variables for Next.js or Remix to specify your routes, such asNEXT_PUBLIC_CLERK_SIGN_IN_URL
, this will be set topath
.
- Name
path
- Type
string
- Description
The path where the component is mounted on when path-based routing is used
For example:/sign-up
.
This prop is ignored in hash- and virtual-based routing.
- Name
redirectUrl
- Type
string
- Description
Full URL or path to navigate to after successful sign in or sign up.
The same as settingafterSignInUrl
andafterSignUpUrl
to the same value.
- Name
afterSignInUrl
- Type
string
- Description
The full URL or path to navigate to after a successful sign in.
- Name
signInUrl
- Type
string
- Description
Full URL or path to the sign in page. Use this property to provide the target of the 'Sign In' link that's rendered.
- Name
afterSignUpUrl
- Type
string
- Description
The full URL or path to navigate to after a successful sign up.
- Name
unsafeMetadata
- Type
object
- Description
An object with the key and value for
unsafeMetadata
that will be saved to the user after sign up.
For example:{ "company": "companyID1234" }
- Name
initialValues
- Type
SignUpInitialValues
- Description
The values used to prefill the sign-up fields with.
Usage with frameworks
The following example includes basic implementation of the <SignIn />
component. You can use this as a starting point for your own implementation.
The following example demonstrates how you can use the <SignUp />
component on a public page.
If you would like to create a dedicated /sign-up
page in your Next.js application, check out the dedicated guide..
import { SignUp, useUser } from "@clerk/nextjs";
export default function Home() {
const { user } = useUser();
if (!user) {
return <SignUp />;
}
return <div>Welcome!</div>;
}
import { SignUp } from "@clerk/clerk-react";
function SignUpPage() {
return <SignUp />;
}
import { SignUp } from "@clerk/remix";
export default function SignUpPage() {
return (
<div style={{ border: "2px solid blue", padding: "2rem" }}>
<h1>Sign Up route</h1>
<SignUp routing="path" path="/sign-up" />
</div>
);
}
import { SignUp } from "gatsby-plugin-clerk";
export default function SignUpPage() {
return (
<div style={{ border: "2px solid blue", padding: "2rem" }}>
<h1>Sign Up route</h1>
<SignUp routing="path" path="/sign-up" />
</div>
);
}
Usage with JavaScript
The following methods available on an instance of the Clerk
class are used to render and control the <SignUp />
component:
The following examples assume that you have followed the quickstart in order to add Clerk to your JavaScript application.
mountSignUp()
Render the <SignUp />
component to an HTML <div>
element.
function mountSignUp(node: HTMLDivElement, props?: SignUpProps): void;
- Name
node
- Type
HTMLDivElement
- Description
The
<div>
element used to render in the<SignUp />
component
- Name
props?
- Type
SignUpProps
- Description
The properties to pass to the
<SignUp />
component.
import Clerk from "@clerk/clerk-js";
// Initialize Clerk with your Clerk publishable key
const clerk = new Clerk("YOUR_PUBLISHABLE_KEY");
await clerk.load();
document.getElementById("app").innerHTML = `
<div id="sign-up"></div>
`;
const signUpDiv = document.getElementById("sign-up");
clerk.mountSignUp(signUpDiv);
<!-- Add a <div id="sign-up"> element to your HTML -->
<div id="sign-up"></div>
<!-- Initialize Clerk with your
Clerk Publishable key and Frontend API URL -->
<script
async
crossorigin="anonymous"
data-clerk-publishable-key="YOUR_PUBLISHABLE_KEY"
src="https://YOUR_FRONTEND_API_URL/npm/@clerk/clerk-js@latest/dist/clerk.browser.js"
type="text/javascript"
></script>
<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;
- Name
node
- Type
HTMLDivElement
- Description
The container
<div>
element with a rendered<SignUp />
component instance
import Clerk from "@clerk/clerk-js";
// Initialize Clerk with your Clerk publishable key
const clerk = new Clerk("YOUR_PUBLISHABLE_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);
<!-- Add a <div id="sign-up"> element to your HTML -->
<div id="sign-up"></div>
<!-- Initialize Clerk with your
Clerk Publishable key and Frontend API URL -->
<script
async
crossorigin="anonymous"
data-clerk-publishable-key="YOUR_PUBLISHABLE_KEY"
src="https://YOUR_FRONTEND_API_URL/npm/@clerk/clerk-js@latest/dist/clerk.browser.js"
type="text/javascript"
></script>
<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;
- Name
props?
- Type
SignUpProps
- Description
The properties to pass to the
<SignUp />
component
import Clerk from "@clerk/clerk-js";
// Initialize Clerk with your Clerk publishable key
const clerk = new Clerk("YOUR_PUBLISHABLE_KEY");
await clerk.load();
clerk.openSignUp();
<!-- Initialize Clerk with your
Clerk Publishable key and Frontend API URL -->
<script
async
crossorigin="anonymous"
data-clerk-publishable-key="YOUR_PUBLISHABLE_KEY"
src="https://YOUR_FRONTEND_API_URL/npm/@clerk/clerk-js@latest/dist/clerk.browser.js"
type="text/javascript"
></script>
<script>
window.addEventListener("load", async function () {
await Clerk.load();
Clerk.openSignUp();
});
</script>
closeSignUp()
Closes the sign up overlay.
function closeSignUp(): void;
import Clerk from "@clerk/clerk-js";
// Initialize Clerk with your Clerk publishable key
const clerk = new Clerk("YOUR_PUBLISHABLE_KEY");
await clerk.load();
clerk.openSignUp();
// ...
clerk.closeSignUp();
<!-- Initialize Clerk with your
Clerk Publishable key and Frontend API URL -->
<script
async
crossorigin="anonymous"
data-clerk-publishable-key="YOUR_PUBLISHABLE_KEY"
src="https://YOUR_FRONTEND_API_URL/npm/@clerk/clerk-js@latest/dist/clerk.browser.js"
type="text/javascript"
></script>
<script>
window.addEventListener("load", async function () {
await Clerk.load();
Clerk.openSignUp();
// ...
Clerk.closeSignUp();
});
</script>
Customization
To learn about how to customize Clerk components, see the customization documentation.
Feedback
Last updated on