The starting point for any Solid Web App is to obtain the user’s WebID. The WebID is a URL at which one can find information about the user, and where to read or write data. The WebID will be provided by the user’s Identity Provider (which is usually their Pod Provider), but any interaction with a user’s Pod will require explicit permission to be granted by the Pod owner.

To obtain this permission, we will be using solid-auth-client. Its usage is relatively straightforward:

  1. Check if the user has already logged in.
  2. If not, ask the user for their Identity Provider.
  3. Then call auth.login() with the Identity Provider as the first argument.

You can ask the user for their Identity Provider using a regular <input type="url">, or using a convenience library that suggests the most commonly used Providers — at the time of writing, solid.community and inrupt.net.

In code, that process would look roughly as follows:

import auth from 'solid-auth-client';

async function getWebId() {
  /* 1. Check if we've already got the user's WebID and access to their Pod: */
  let session = await auth.currentSession();
  if (session) {
    return session.webId;
  }

  /* 2. User has not logged in; ask for their Identity Provider: */
  // Implement `getIdentityProvider` to get a string with the user's Identity Provider (e.g.
  // `https://inrupt.net` or `https://solid.community`) using a method of your choice.
  const identityProvider = await getIdentityProvider();

  /* 3. Initiate the login process - this will redirect the user to their Identity Provider: */
  auth.login(identityProvider);
}

Edit on CodeSandbox

Next: Understanding Solid