Web SDK

@unet/id-web signs people in with UNET and calls the UNET API from a browser app. What it is, what it is for, and where to start.

@unet/id-web is the JavaScript SDK for browsers. It does the parts of "Sign in with UNET" that are easy to get wrong, and gives your app a typed client for the UNET API. It has no dependencies.

Two things in one package

An app can use either part, or both. They are different products with different rules, so it helps to know which one you are building.

Sign in with UNETA UNET client
You wantto know who the person isto act as the person inside UNET
You usesignIn, handleRedirectCallback, getUser, verifyAccessToken, verifyIdTokenunet.api.* (feed, posts, follows, notifications, ...)
Permissionsnone beyond sign-in (openid profile)one permission per kind of call, shown to the person
The id you geta different one on every site, by defaultthe UNET user id (the API shows real ids)
Your serververifies the token it is senthas nothing to verify: UNET checks every request

Read Sign in vs a UNET client once; it saves a lot of confusion later.

What is in the box

  • Sign-in with the authorization code flow and PKCE. You never handle a password, a key or a client secret.
  • Sessions that refresh by themselves, survive several tabs, and end cleanly when the person removes your app.
  • A typed API client: feed, posts, comments, profiles, search, notifications, library, safety, settings, the Fediverse, media, and live updates over server-sent events.
  • Server-side checks for the token your front end sends to your own backend.
  • Debugging: every request the SDK makes can be traced, with secrets redacted.

Where to start

What the SDK does not do

  • It does not run on a server: the sign-in and the API client need a browser. Only verifyAccessToken and verifyIdToken are meant for your server.
  • It does not give you the person's email address. UNET accounts have none.
  • It is not a UI kit: there is no button or modal in the package. The brand page has the official button.