Reference · React
<TechneProvider>
React componenttechne-sdk/auth/react
Wraps your app. Give it your clientId and every hook below it can sign people in, read and write.
On mount it restores the last session. Until then, and whenever nobody is signed in, the hooks read public records, so the page renders at once.
The whole setup
How sign-in works
- Your
clientIdis a URL on your own domain. It points to a small JSON file that names your app, its logo, where sign-in returns to and what it asks to do. - The person's PDS reads that file. It shows them your app's name and what it asks for, and they say yes or no. Their PDS can be techne.town or any other.
- Nobody approves apps ahead of time. Neither Techne nor the PDS does. There is nothing to register.
- On localhost, skip the file. Leave
clientIdout while you develop and sign-in still works. Before you ship, serve the file and pass its URL.
Serve the file.
clientMetadata writes it.It answers client_id, client_name, logo_uri, redirect_uris (your origin by default) and the scope the SDK asks for. That scope is atproto, Techne's read and write permission sets, and the public calendar records.
Props
| Name | Type | What it is |
|---|---|---|
clientId | string | The https URL of your client metadata file. Leave it out on localhost. |
handle | string | The handle <SignInWithTechne /> starts with when it is given none. A bare name is a techne.town one. |
platform | string | The platform's service DID. Default did:web:techne.computer. |
claims | Claims | The claims every read is checked over. Pass it memoised. A new one makes a new client. |
onError | (error) => void | Hears a failed restore or sign-in. Without it, console.error. |
Also scope, fetch and plcUrl, which most apps never set.
Below it
| Name | Type | What it is |
|---|---|---|
useTechne() | Techne | The client every read and write goes through. Signed out, it reads public records; put asks you to sign in. useTechne |
useSession() | OAuthSession | null | The session, or null while restoring or when signed out. useSession |
useAuthStatus() | 'restoring' | 'signed-in' | 'signed-out' | Where sign-in stands, for a screen that would rather wait. |
useSignOut() | () => Promise<void> | Signs the person out and revokes the session at their PDS. |
<SignInWithTechne /> | button | The sign-in button. signUp makes it create an account at techne.town. SignInWithTechne |
Every read hook works below it too. They are useRecordQuery, useRecord and useVersions.
Without React, use connect →