|
1 | 1 | # Examples |
2 | 2 |
|
3 | 3 | - [Passing authorization parameters](#passing-authorization-parameters) |
| 4 | + - [Social Login](#social-login) |
| 5 | + - [Passwordless (via Universal Login)](#passwordless-via-universal-login) |
| 6 | + - [Showing the signup screen](#showing-the-signup-screen) |
| 7 | + - [Pre-filling the login field](#pre-filling-the-login-field) |
4 | 8 | - [The `returnTo` parameter](#the-returnto-parameter) |
5 | 9 | - [Redirecting the user after authentication](#redirecting-the-user-after-authentication) |
6 | 10 | - [Redirecting the user after logging out](#redirecting-the-user-after-logging-out) |
@@ -177,6 +181,82 @@ The second option is through the query parameters to the `/auth/login` endpoint |
177 | 181 | <a href="/auth/login?audience=urn:my-api">Login</a> |
178 | 182 | ``` |
179 | 183 |
|
| 184 | +### Social Login |
| 185 | + |
| 186 | +To skip the Universal Login page and send users directly to a social provider, pass the `connection` parameter with the Auth0 connection name: |
| 187 | + |
| 188 | +```html |
| 189 | +<a href="/auth/login?connection=google-oauth2">Continue with Google</a> |
| 190 | +<a href="/auth/login?connection=github">Continue with GitHub</a> |
| 191 | +<a href="/auth/login?connection=facebook">Continue with Facebook</a> |
| 192 | +``` |
| 193 | + |
| 194 | +Or configure it statically for all logins: |
| 195 | + |
| 196 | +```ts |
| 197 | +export const auth0 = new Auth0Client({ |
| 198 | + authorizationParameters: { |
| 199 | + connection: "google-oauth2" |
| 200 | + } |
| 201 | +}); |
| 202 | +``` |
| 203 | + |
| 204 | +### Passwordless (via Universal Login) |
| 205 | + |
| 206 | +Auth0 supports passwordless login using email magic links/OTP or SMS OTP through the Universal Login page. The SDK forwards the `connection` parameter to Auth0, which handles the entire passwordless flow and redirects back to your app with a standard authorization code. |
| 207 | + |
| 208 | +Prerequisites: |
| 209 | + |
| 210 | +- Enable the **Email** or **SMS** passwordless connection in the [Auth0 Dashboard](https://manage.auth0.com) under **Authentication > Passwordless**. |
| 211 | +- Add the connection to your application. |
| 212 | + |
| 213 | +**Email passwordless:** |
| 214 | + |
| 215 | +```html |
| 216 | +<!-- Auth0 will send a magic link or OTP to the user's email --> |
| 217 | +<a href="/auth/login?connection=email">Login with Email</a> |
| 218 | +``` |
| 219 | + |
| 220 | +**SMS passwordless:** |
| 221 | + |
| 222 | +```html |
| 223 | +<!-- Auth0 will send an OTP to the user's phone number --> |
| 224 | +<a href="/auth/login?connection=sms">Login with SMS</a> |
| 225 | +``` |
| 226 | + |
| 227 | +The user experience on the Auth0-hosted page (magic link vs. OTP code) is configured in the Auth0 Dashboard under the connection settings. Your application code does not change — the callback and session creation work identically to any other login. |
| 228 | + |
| 229 | +### Showing the signup screen |
| 230 | + |
| 231 | +To send users directly to the registration form instead of the login form: |
| 232 | + |
| 233 | +```html |
| 234 | +<a href="/auth/login?screen_hint=signup">Create account</a> |
| 235 | +``` |
| 236 | + |
| 237 | +Or statically: |
| 238 | + |
| 239 | +```ts |
| 240 | +export const auth0 = new Auth0Client({ |
| 241 | + authorizationParameters: { |
| 242 | + screen_hint: "signup" |
| 243 | + } |
| 244 | +}); |
| 245 | +``` |
| 246 | + |
| 247 | +### Pre-filling the login field |
| 248 | + |
| 249 | +To pre-fill the email or phone number field on the Universal Login page: |
| 250 | + |
| 251 | +```ts |
| 252 | +// In a Server Action or Route Handler |
| 253 | +const response = await auth0.startInteractiveLogin({ |
| 254 | + authorizationParameters: { |
| 255 | + |
| 256 | + } |
| 257 | +}); |
| 258 | +``` |
| 259 | + |
180 | 260 | ## The `returnTo` parameter |
181 | 261 |
|
182 | 262 | ### Redirecting the user after authentication |
|
0 commit comments