···2233try it here: http://flo-bit.dev/svelte-atproto-client-oauth/
4455-this is a scaffold for how to get client side oauth working with sveltekit and atproto
55+this is a scaffold for how to get client side oauth working with sveltekit and atproto
66using the [`atcute`](https://github.com/mary-ext/atcute) libraries.
7788-useful when you want people to login to your static sveltekit site.
88+useful when you want people to login with atproto to your static sveltekit site.
991010## how to install
1111···3131};
3232```
33333434+6. change the SITE in `$lib/atproto/settings.ts` to your website
3535+3636+7. setup the correct permissions (see below)
3737+3438### or manually install in your own project
35393636-1. copy the `src/lib/oauth` folder into your own project
3737-2. also copy the `src/routes/oauth-client-metadata.json.json` folder into your project
4040+1. copy the `src/lib/atproto` folder into your own project
4141+2. also copy the `src/routes/oauth-client-metadata.json` folder into your project
38423. initialize the client in your `src/routes/+layout.svelte`
39434044```svelte
···6872npm install @atcute/atproto @atcute/bluesky @atcute/identity-resolver @atcute/lexicons @atcute/oauth-browser-client @atcute/client
6973```
70747171-6. set your base in `svelte.config.js` (e.g. for github pages: `base: '/your-repo-name/'`) while keeping it as `''` in development.
7575+6. (optionally) set your base in `svelte.config.js` (e.g. for github pages: `base: '/your-repo-name/'`) while keeping it as `''` in development.
7676+72777378```ts
7479const config = {
···8489};
8590```
86919292+6. change the SITE in `$lib/atproto/settings.ts` to your website
9393+9494+7. setup the correct permissions (see below)
9595+87968897## how to use
89989999+### set permissions you request on sign-in in `$lib/atproto/settings.ts` (see commented out examples for more info)
100100+101101+- add collections to the collections array
102102+- add rpcs to rpcCalls
103103+- blobs for uploading blobs
104104+105105+### change sign up pds
106106+107107+If you want to allow sign-up, change the `signUpPDS` variable in `$lib/atproto/settings.ts` to a pds of your choice
108108+109109+ATTENTION: the current setting (pds.rip) is only for development, all accounts get deleted automatically after a week
110110+90111### login flow
9111292113Either use the `LoginModal` component to render a login modal or use the `user` object to handle the login flow yourself.
···102123user.logout();
103124```
104125105105-LoginModal is a component that renders a login modal, add it for a quick login flow.
106106-(copy the `src/lib/UI` folder into your projects `src/lib` folder)
126126+LoginModal is a component that renders a login modal, add it for a quick login flow (needs tailwind).
127127+(copy the `src/lib/UI` folder into your projects `src/lib` folder, add the `src/app.css` content to your `app.css`)
107128108129```svelte
109130<script>
···123144import { user } from '$lib/oauth';
124145125146// make requests with the user.client object
147147+// this example needs the getActorLikes rpc permission, set permissions
126148const response = await user.client.get('app.bsky.feed.getActorLikes', {
127149 params: {
128150 actor: client.did,