# @sanity/default-login

> Lets the user log in to Sanity.

Latest version **2.36.2** (published 2023-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sanity/default-login
pnpm add @sanity/default-login
yarn add @sanity/default-login
bun add @sanity/default-login
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.36.2 |
| Published | 2023-07-25 |
| First published | 2016-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 46.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sanity.io |
| Maintainers | jonabc, kenjonespizza, pauloborgesf, binoy14, simen.svale, benjaminakar, svirs, josh_sanity_io, joneidejohnsen, nina.andal, rankers, snorreeb, mattcraig, vincentquigley, stipsan, michael-sanity, rubioz, tonina, ritasdias, simeonsanity, kmelve, bjoerge, rexxars, skogsmaskin, robinpyon, mariuslundgard, sanity-io, evenw, radhe_sanity, rbotten, vicbergquist, judofyr, obliadp, dcilke, fredcarlsen, hermanw, mikolajsanity, sgulseth, atombender |
| Keywords | sanity, cms, headless, realtime, content, default-login, sanity-plugin |

## Links

- npm: https://www.npmjs.com/package/@sanity/default-login
- Repository: https://github.com/sanity-io/sanity
- Homepage: https://www.sanity.io/
- Issues: https://github.com/sanity-io/sanity/issues
- npm.io page: https://npm.io/package/@sanity/default-login

## Dependencies (7)

- [rxjs](https://npm.io/package/rxjs.md) ^6.5.3
- [@sanity/ui](https://npm.io/package/@sanity/ui.md) ^0.37.22
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0
- [@sanity/base](https://npm.io/package/@sanity/base.md) 2.36.2
- [@sanity/logos](https://npm.io/package/@sanity/logos.md) ^1.1.15
- [@sanity/client](https://npm.io/package/@sanity/client.md) ^3.3.3
- [@sanity/generate-help-url](https://npm.io/package/@sanity/generate-help-url.md) ^3.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.36.2 (latest) — 2023-07-25
- 2.36.6 (v2) — 2024-11-07
- 2.36.2-weighted-search.16 (weighted-search) — 2023-07-14
- 2.34.3-cdr-ga-4.23 (cdr-ga-4) — 2022-10-20
- 2.34.3-cdr-ga-2.19 (cdr-ga-2) — 2022-10-20
- 2.34.3-cdr-ga.20 (cdr-ga) — 2022-10-20
- 2.34.3-cdr-preview.20 (cdr-preview) — 2022-10-20
- 2.34.2-empty-template-cli.0 (empty-template-cli) — 2022-10-13
- 2.34.1-canary.0 (canary) — 2022-10-12
- 2.33.4-shopify.8 (shopify) — 2022-09-22
- 2.33.4-performance-opts.16 (performance-opts) — 2022-09-22
- 2.33.3-edge.8 (edge) — 2022-09-20
- 2.30.7-findability.87 (findability) — 2022-09-20
- 2.33.1-performance-opts-doc-pane.2 (performance-opts-doc-pane) — 2022-09-12
- 2.32.1-next.22 (next) — 2022-09-08
- … 747 more at https://npm.io/package/@sanity/default-login/versions

## README

# ⚠️ THIS PACKAGE IS DEPRECATED

> This package is part of Sanity Studio v2, which has been superseded by **Sanity Studio v3**, the current major version released on Dec 7th, 2022. This package is no longer used/needed for Sanity Studio in its current version and will be retired on Dec 7th, 2023. The core packages for Sanity Studio v2 will only receive critical bug fixes until this date.
>
> Please head over to [the documentation for Sanity Studio v3](https://www.sanity.io/docs/sanity-studio) to learn more.

# @sanity/default-login

Let a user log into Sanity, and get access to the child content.

## Configuration

By default this component will ask the Sanity API and get a list of providers, which the user can login with.

However it is possible for enterprise customers to supply their own third party authentication server as a provider as well.

This is done through configuring the studio with the file `./config/@sanity/default-login.json`

Example:

```
{
  "providers": {
    // Append the custom providers to the default providers or replace them.
    "mode": "append", // default - or 'replace'

    // If true, don't show the choose provider logo screen,
    // automatically redirect to the single provider login
    "redirectOnSingle": false // default

    // The custom provider implementations
    "entries": [
      {
        "name": "vandelay",
        "title": "Vandelay Industries",
        "url": "https://api.vandelay.industries/login",
        "logo": "/static/img/vandelay.svg" // Optional, put it in the studio static folder
      }
    ]
  },

  // Login method to use for the studio the studio. Can be one of:
  // `dual` (default) - attempt to use cookies where possible, falling back to storing authentication token in `localStorage` otherwise
  // `cookie` - explicitly disable `localStorage` method, relying only on cookies
  "loginMethod": "dual"
}
```

## Using the component

```
<LoginWrapper>
  {user => <Layout><div>{user.name} is logged in!</div></Layout>}
</LoginWrapper>

```

### Props

```
static propTypes = {
  children: PropTypes.oneOfType([
    PropTypes.node,
    PropTypes.func
  ]).isRequired,
  title: PropTypes.string,
  description: PropTypes.string,
  SanityLogo: PropTypes.func
}
```

```
static defaultProps = {
  title: 'Choose login provider',
  description: null,
  SanityLogo: SanityStudioLogo,
}
```

---
_Source: https://npm.io/package/@sanity/default-login · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
