Muokkaa

Jaa


Single-page application: Code configuration

Learn how to configure the code for your single-page application (SPA).

Microsoft libraries supporting single-page apps

The following Microsoft libraries support single-page apps:

Language / framework Project on
GitHub
Package Getting
started
Sign in users Access web APIs Generally available (GA) or
Public preview1
Angular MSAL Angular v22 msal-angular Quickstart Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
Angular MSAL Angular3 msal-angular Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
AngularJS MSAL AngularJS3 msal-angularjs Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. Public preview
JavaScript MSAL.js v22 msal-browser Tutorial Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
JavaScript MSAL.js 1.03 msal-core Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
React MSAL React2 msal-react Quickstart Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA

1 Universal License Terms for Online Services apply to libraries in Public preview.

2 Auth code flow with PKCE only (Recommended).

3 Implicit grant flow only (Not recommended).

Application code configuration

In an MSAL library, the application registration information is passed as configuration during the library initialization.

import * as Msal from "@azure/msal-browser"; // if using CDN, 'Msal' will be available in global scope

// Configuration object constructed.
const config = {
    auth: {
        clientId: 'your_client_id'
    }
};

// create PublicClientApplication instance
const publicClientApplication = new Msal.PublicClientApplication(config);

For more information on the configurable options, see Initializing application with MSAL.js.

Next steps

Move on to the next article in this scenario, Sign-in and sign-out.