Get started with Microsoft Graph Toolkit
Watch this short video to get started using the toolkit.
For a step-by-step tutorial, see the Get started with Microsoft Graph Toolkit module.
Set up your Microsoft 365 tenant
To use Microsoft Graph Toolkit to develop an app, 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 need the following:
- A text editor or IDE. You can use the editor or IDE of your choice, or you can install and use Visual Studio Code for free.
- A modern web browser such as Microsoft Edge, Google Chrome, or Firefox.
- An LTS version of Node.js, which you can install from nodejs.org.
Use Microsoft Graph Toolkit
You can use Microsoft Graph Toolkit in your application by referencing the loader directly (via
unpkg) or by installing the
To use the toolkit via
mgt-loader, add the reference in a script to your code:
<script src="https://unpkg.com/@microsoft/mgt@2/dist/bundle/mgt-loader.js"></script> <mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"></mgt-msal2-provider> <mgt-login></mgt-login>
Microsoft Graph Toolkit is made up of several NPM packages, allowing you to only include the code that you need for your applications.
@microsoft/mgt-element is the core package that contains only the base classes used for building components and providers. This package exposes all the necessary classes and interfaces that you need to build your own components, and exports the IProvider interface and SimpleProvider class for building custom providers.
@microsoft/mgt-components package contains all the Microsoft Graph connected web components, such as
PeoplePicker, and more.
Providers are available via a single package and can be installed as needed. The following provider packages are available:
mgt-msal2-providercomponent. The MSAL2 provider uses msal-browser for authenticating in web apps and PWAs.
SharePointProviderfor authenticating in a SharePoint environment.
ProxyProviderfor an application that proxy Graph calls through a backend service.
@microsoft/mgt package is the main package that includes all the preceding packages and re-exports them so they are available via a single package that you can install.
@microsoft/mgt-react package contains all the auto-generated React components and takes dependency on the
@microsoft/mgt-spfx package contains a SharePoint Framework library that's required to use Microsoft Graph Toolkit in SharePoint Framework solutions.
@microsoft/mgt-spfx-utils package contains a helper function to assit with lazy loading for disambiguation when using Microsoft Graph Toolkit in SharePoint Framework solutions.
You're now ready to start developing with Microsoft Graph Toolkit! The following guides are available to help you get started: