Reference · React

<TechneProvider>

Next release: this page describes techne-sdk/auth/react, which is not in techne-sdk 0.3.4 yet. With techne-sdk 0.3 today shows the released API.

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

  1. Your clientId is 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.
  2. 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.
  3. Nobody approves apps ahead of time. Neither Techne nor the PDS does. There is nothing to register.
  4. On localhost, skip the file. Leave clientId out 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

NameTypeWhat it is
clientIdstringThe https URL of your client metadata file. Leave it out on localhost.
handlestringThe handle <SignInWithTechne /> starts with when it is given none. A bare name is a techne.town one.
platformstringThe platform's service DID. Default did:web:techne.computer.
claimsClaimsThe claims every read is checked over. Pass it memoised. A new one makes a new client.
onError(error) => voidHears a failed restore or sign-in. Without it, console.error.

Also scope, fetch and plcUrl, which most apps never set.

Below it

NameTypeWhat it is
useTechne()TechneThe client every read and write goes through. Signed out, it reads public records; put asks you to sign in. useTechne
useSession()OAuthSession | nullThe 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 />buttonThe 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 →