Tutorial

This tutorial creates an introductory application that uses Inrupt’s JavaScript client libraries to:

  • Login a user.

  • Reads the Pod URL(s) associated with the user’s WebID. A WebID is a URL that identifies a user and dereferences to the user’s WebID profile document.

  • Write a reading list to the user’s Pod.

The tutorial uses npm and webpack to run the application locally on http://localhost:8080/ .

Prerequisites

Install npm

If you do not already have npm installed, install npm. npm is installed as part of the Node.js installation.

Inrupt’s Javascript Client libraries support Active/Maintenance LTS releases for Node.js.

Note

  • This tutorial uses Inrupt’s PodSpaces and provides instructions on creating an account, WebID and a Pod through PodSpaces.

  • PodSpaces is currently available as Developer Preview. Do not use for production or storing sensitive/personal data.

To get a WebID and a Pod on PodSpaces :

  1. Go to PodSpaces.

  2. To create an account, you must agree to the Inrupt’s Terms of Service. To agree, select the checkbox.

  3. If you agree to Inrupt’s Terms of Service, click on the Sign Up button.

  4. If you have not registered an account with the Inrupt Identity Provider, click on the Sign up link to create an account:

    1. Fill in your username, email, and password.

    2. Click Sign Up. You are sent a verification email.

    3. Check your email for the verification email. Follow the instructions in the email to verify. Check your spam if you do not see the email in your inbox.

    4. Once verified, return to click Continue to go to the Sign in page:

      1. Enter your username and password.

      2. Click Sign in to your account. The screen displays the access required to continue.

    5. To allow and continue, click Allow. The application displays your WebID and Pod Storage details:

      1. WebID: https://id.inrupt.com/{username} . Pod Storage: https://storage.inrupt.com/{Root Container}

Build the Application

1. Initialize the Application

  1. Create the directory structure for your Webpack project:

  2. Go to the newly created my-demo-app directory.

  3. Initialize the application.

  • To accept the default values for the application without prompts:

  • Or, to be prompted to enter values for the application:

    1. You can either hit return to accept the default values (including empty values) or supply your own values.

    2. When prompted Is this OK? (yes) , enter to accept yes .

2. Install the Client Libraries

  1. Use npm to install the solid-client , @inrupt/solid-client-authn-browser , vocab-common-rdf , and vocab-solid libraries:

3. Install Webpack

  1. Use npm to install Webpack packages:

  2. In my-demo-app directory, create a webpack.config.js file with the following content:

  3. In my-demo-app directory, edit the package.json file to add build and start script fields to scripts :

Be sure to add the comma after the preceding field value before adding the build and start fields.

4. Create the Application

In the my-demo-app directory, create the files for the application. For an explanation of the JavaScript code used in this tutorial, see Explanation

A. Create the CSS File

In the my-demo-app/dist folder, create a my-demo.css file with the following content:

B. Create the HTML File

In the my-demo-app/dist , create an index.html file with the following content:

If you are not using your PodSpaces account, you can modify the select-idp options.

C. Create the JS File

In the my-demo-app/src , create an index.js file with the following content:

For details about the JavaScript code, see Explanation.

5. Run the Application

  1. In the my-demo-app directory, run:

    The output resembles the following:

  2. Open localhost:8080 in a browser.

  3. Login.

    1. Select the Identity Provider and click Login.

    2. If you have logged out of your Pod, you are prompted to sign in. Enter your username and password and sign in. You will be prompted to allow this application the specified access. To continue, click Continue.

    3. You are redirected back to your page. Your WebID is now displayed in the application.

  4. Click Get Pod URL . The application populates the Pods selection box (in panel 3) with the Pod URL from your profile document.

  5. Write your reading list to your Pod.

    1. Select your Pod URL.

    2. Edit your reading list.

    3. Click Create to to save the list to your Pod.

The reading list is saved to your Pod at https://storage.inrupt.com/<root container>/getting-started/readingList/myList .

Upon successful save, the application displays the saved reading list in the next panel.

For details about the example code, see Explanation

6. Exit the Application

To exit the application, stop the npm run start process; e.g., Ctrl-C .

Additional Information

Last updated