Skip to main content

Sign up

This guide shows how to implement a secure sign up flow that authenticates users and creates sessions.

You'll learn how to:

  • Redirect the user to the Ory registration page to start the sign up flow
  • Redirect the user back to your application after sign up
  • Check if the user is authenticated

To authenticate a user, check if the user has an active session. If the user does not have an active session, redirect the user to the Ory registration page.

app.get("/", (req, res) => {
ory
.toSession({ cookie: req.header("cookie") })
.then((data) => res.json(data))
.catch(() =>
res.redirect(
`${process.env.ORY_SDK_URL}/self-service/registration/browser`,
),
)
})

You can alternatively set return_to to a custom URL. This URL will be used as the return URL for the sign up flow:

https://$ORY_SDK_URL/self-service/registration/browser?return_to=https://example.com/dashboard