Getting started with the Microsoft Graph Toolkit

The Microsoft Graph Toolkit components can easily be added to your web application, SharePoint web part, or Microsoft Teams tabs. The components are based on web standards and can be used in both plain JavaScript projects or with popular web frameworks such as Reach, Angular, Vue.js, and more.

You can watch this short video to see how quick and easy it is to get started with the Toolkit.

For a step-by-step tutorial, see the Get started with Microsoft Graph Toolkit module.

Set up your Microsoft 365 tenant

In order to develop with the Toolkit, you need access to a Microsoft 365 tenant. If you don't have one, you can get a free Microsoft 365 developer subscription by joining the Microsoft 365 Developer Program. For details about how to configure your subscription, see Set up a Microsoft 365 developer subscription.

Set up your development environment

To develop with the Toolkit, you will need a text editor or IDE. You can use the editor or IDE of your choice or install and use Visual Studio Code for free. You will also need a modern web browser like Microsoft Edge, Google Chrome, or Firefox. You'll also need an LTS version of Node.js, which you can install from nodejs.org.

Using the Microsoft Graph Toolkit

You can use the Microsoft Graph Toolkit in your application by referencing the loader directly (via unpkg) or by installing the npm package.

To use the Toolkit via mgt-loader, add the reference in a script to your code:

<script src="https://unpkg.com/@microsoft/mgt/dist/bundle/mgt-loader.js"></script>

<mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"></mgt-msal2-provider>
<mgt-login></mgt-login>

NPM packages

The Microsoft Graph Toolkit is made up of several NPM packages, allowing you to only include the code you need for your applications.

@microsoft/mgt-element

The @microsoft/mgt-element is the core package that contains only the base classes used for building components and providers. This package exposes all necessary classes and interfaces needed to build your own components and exports the IProvider interface and SimpleProvider class for building custom providers.

@microsoft/mgt-components

The @microsoft/mgt-components package contains all Microsoft Graph connected web components, such as Person, PeoplePicker, and more.

Providers

Providers are available via a single package and can be installed as needed. The following provider packages are available:

  • @micosoft/mgt-msal-provider

    @micosoft/mgt-msal-provider contains the MsalProvider and mgt-msal-provider component. The MSAL provider uses msal.js for authenticating in web apps and Progressive Web Apps (PWAs).

  • @micosoft/mgt-msal2-provider

    @micosoft/mgt-msal2-provider contains the Msal2Provider and mgt-msal2-provider component. The MSAL2 provider uses msal-browser for authenticating in web apps and PWAs.

  • @microsoft/mgt-teams-provider

    @microsoft/mgt-teams-provider contains the TeamsProvider and mgt-teams-provider component. The Microsoft Teams provider enables authentication in Microsoft Teams tab application.

  • @microsoft/mgt-teams-msal2-provider

    @microsoft/mgt-teams-msal2-provider contains the TeamsMsal2Provider and mgt-teams-msal2-provider component. The Microsoft Teams MSAL2 provider enables authentication in Microsoft Teams tab application.

  • @microsoft/mgt-sharepoint-provider

    @microsoft/mgt-sharepoint-provider contains the SharePointProvider for authenticating in a SharePoint environment.

  • @microsoft/mgt-proxy-provider

    @microsoft/mgt-proxy-provider contains the ProxyProvider for application that proxy Graph calls through a backend service.

@microsoft/mgt

The @microsoft/mgt is the main package that includes all above packages and re-exports them so they are available via a single package you can install.

@microsoft/mgt-react

The @microsoft/mgt-react package contains all auto-generated React components and takes dependency on the @microsoft/mgt package.

@microsoft/mgt-spfx

The @microsoft/mgt-spfx package contains a SharePoint Framework library that's required to use Microsoft Graph Toolkit in SharePoint Framework solutions.

Next Steps

You're now ready to start developing with the Microsoft Graph Toolkit! The following guides are available to help you get started: