# Social Login (/sdk/v5_3_x/advanced/social-login)

> For the complete documentation index, see [llms.txt](/llms.txt)



<VersionWarning version="5.3.x" />

Social login allows users to authenticate using their existing social media accounts such as Google or Facebook.

ZeroDev supports social logins natively, but you can also use ZeroDev with [third-party auth providers](/sdk/v5_3_x/signers/intro) such as Dynamic, Privy, and Magic if you prefer their UI.

## Setup [#setup]

ZeroDev offers two modes for setting up social login: Development and Production. Follow the steps below to configure your social login in our [dashboard](https://dashboard.zerodev.app/auth-options).

* **Development Mode**:
  * Available to all users by default.
  * Functions only when your application is running locally on the `localhost` URI.
  * Ideal for testing social sign-in features during development.

* **Production Mode**:
  * Available to users on the "Growth" plan or higher.
  * To activate, complete the form in the [Social Auth](https://dashboard.zerodev.app/auth-options) section of the ZeroDev dashboard.
  * Submit the form for review; reviews are typically completed within 24 hours.
  * Ensure all sections of the form are completed accurately to facilitate a successful review.
  * ZeroDev uses [Magic](https://magic.link/docs/home/security/product-security) for its social integration. Links to Magic's documentation are provided in the form to assist with setup (e.g., Google Developer Console).

**Production Mode Configuration Steps**:

1. Enter the client ID and client secret from your social provider into the designated fields in the ZeroDev dashboard.
2. Copy the redirect URI provided by ZeroDev into your social provider’s dashboard.
3. Ensure that the redirect URI and whitelist URI for your application are input correctly in the form.
4. Submit the form for review.

For detailed information on how Magic handles the creation of public/private key pairs, integral to the security of the social login process, please refer to [Magic's product security documentation.](https://magic.link/docs/home/security/product-security)

## Installation [#installation]

<Tabs items="[&#x22;npm&#x22;,&#x22;yarn&#x22;,&#x22;pnpm&#x22;,&#x22;bun&#x22;]">
  <Tab value="npm">
    ```bash
    npm i @zerodev/social-validator
    ```
  </Tab>

  <Tab value="yarn">
    ```bash
    yarn add @zerodev/social-validator
    ```
  </Tab>

  <Tab value="pnpm">
    ```bash
    pnpm i @zerodev/social-validator
    ```
  </Tab>

  <Tab value="bun">
    ```bash
    bun add @zerodev/social-validator
    ```
  </Tab>
</Tabs>

## API [#api]

### `isAuthorized` [#isauthorized]

Checks if the user is authorized. In a web app, this is typically called on page load to check if the user is logged in.

```ts
isAuthorized({ projectId: string }): Promise<boolean>
```

#### Parameters [#parameters]

* projectId (string): Your ZeroDev project ID.

#### Returns [#returns]

* `Promise<boolean>`: Resolves to true if the user is logged in, otherwise false.

#### Example [#example]

```ts
import { isAuthorized } from "@zerodev/social-validator"

const authorized = await isAuthorized({ projectId: 'your_project_id' });
console.log(authorized); // true or false
```

### `initiateLogin` [#initiatelogin]

Initiates a social login process by redirecting the user to the specified OAuth provider.

After a successful login, the user will be redirected back to your app. You may then call the `getSocialValidator` function to create a [Kernel account](/sdk/core-api/create-account#create-a-kernel-account) using the social validator as the sudo validator.

```ts
initiateLogin({
  socialProvider: "google" | "facebook",
  oauthCallbackUrl?: string,
  projectId: string
})
```

#### Parameters [#parameters-1]

* socialProvider ("google" | "facebook"): The social provider to use for login.
* oauthCallbackUrl (string, optional): The URL to redirect to after login. Defaults to the current window location if not provided.
* projectId (string): Your ZeroDev project ID.

#### Example [#example-1]

```ts
import { initiateLogin } from "@zerodev/social-validator"

initiateLogin({
  socialProvider: "google",
  projectId: "your_project_id"
});
```

### `getSocialValidator` [#getsocialvalidator]

Gets a social validator for the specified entry point. Use this function after a successful login to create a [Kernel account](/sdk/core-api/create-account#create-a-kernel-account) using the social validator as the sudo validator.

```ts
getSocialValidator<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined>(
  client: Client<TTransport, TChain, undefined>,
  {
    entryPoint: entryPointAddress,
    projectId: string
  }
): Promise<KernelValidator<entryPoint, "SocialValidator">>
```

#### Parameters [#parameters-2]

* client (Client): The client instance.
* entryPoint (entryPoint): The entry point address.
* projectId (string): Your ZeroDev project ID.

#### Returns [#returns-1]

* `Promise<KernelValidator<entryPoint, "SocialValidator">>`: Resolves to a social validator object.

#### Example [#example-2]

```ts
import { getSocialValidator } from "@zerodev/social-validator"
import { ENTRYPOINT_ADDRESS_V07 } from "permissionless"

const socialValidator = await getSocialValidator(
  publicClient,
  {
    entryPoint: ENTRYPOINT_ADDRESS_V07,
    projectId: "your_project_id"
  }
);
```

<Callout type="info">
  Now you can proceed to [create Kernel accounts](/sdk/core-api/create-account#create-a-kernel-account) using the social validator as the sudo validator.
</Callout>

### `logout` [#logout]

Logs out the current user.

```ts
logout({ projectId: string })
```

#### Parameters [#parameters-3]

* projectId (string): Your ZeroDev project ID.

#### Example [#example-3]

```ts
import { logout } from "@zerodev/social-validator"

await logout({ projectId: "your_project_id" });
```
