Something went wrong. Try again.
Something went wrong. Try again.
Files
README.md
# vue-atproto-login
atproto / Bluesky OAuth sign-in for Vue 3: a composable, a component, and a handle typeahead.
Extracted from three apps that had each grown their own copy of the same flow
([remanso.space](https://remanso.space), [remanso.at](https://remanso.at),
[stt.apoena.dev](https://stt.apoena.dev)). Every place they diverged is now an option;
everything they agreed on is the default.
```bash
pnpm add vue-atproto-login @atproto/oauth-client-browser
```
## Quick start
```ts
// main.ts
import { createApp } from "vue"
import { atprotoLoginPlugin } from "vue-atproto-login"
import "vue-atproto-login/style.css"
createApp(App)
.use(atprotoLoginPlugin({ clientId: "https://my-app.example/client-metadata.json" }))
.mount("#app")
```
```vue
<script setup lang="ts">
import { AtprotoLogin } from "vue-atproto-login"
</script>
<template>
<header>
<AtprotoLogin />
</header>
</template>
```
That is the whole login: a skeleton while auth resolves, the signed-in handle and avatar
once it has, and a handle box with typeahead when it hasn't.
You also need to host a `client-metadata.json` at the URL you passed as `clientId` — in
atproto OAuth the client id *is* that document. See
[`client-metadata.example.json`](./client-metadata.example.json).
## The composable
```vue
<script setup lang="ts">
import { useAtprotoLogin } from "vue-atproto-login"
const { did, handle, avatar, isReady, isLoggedIn, signIn, signOut, getSession } =
useAtprotoLogin()
</script>
```
| | |
|---|---|
| `did` | `null` until auth resolves, then `""` when signed out, else the DID |
| `handle` `displayName` `avatar` `pds` | whatever the profile resolver knows |
| `isReady` | false until the OAuth client answers — render a skeleton, not "Sign in" |
| `isLoggedIn` | |
| `prefillHandle` | writable; seeds the sign-in input |
| `signIn(handle)` | redirects the page to the user's PDS; on success it does not return |
| `signOut()` | revokes the grant at the PDS and clears the local identity |
| `refresh()` | re-resolve handle and avatar |…