Get started with Microsoft Graph Toolkit
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, and Vue.js.
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 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@2/dist/bundle/mgt-loader.js"></script>
<mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"></mgt-msal2-provider>
<mgt-login></mgt-login>
NPM packages
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
The @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
The @microsoft/mgt-components
package contains all the 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:
@microsoft/mgt-msal2-provider
@microsoft/mgt-msal2-provider
contains theMsal2Provider
andmgt-msal2-provider
component. The MSAL2 provider uses msal-browser for authenticating in web apps and PWAs.@microsoft/mgt-sharepoint-provider
@microsoft/mgt-sharepoint-provider
contains theSharePointProvider
for authenticating in a SharePoint environment.@microsoft/mgt-proxy-provider
@microsoft/mgt-proxy-provider
contains theProxyProvider
for an application that proxy Graph calls through a backend service.
@microsoft/mgt
The @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
The @microsoft/mgt-react
package contains all the 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.
@microsoft/mgt-spfx-utils
The @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.
Next steps
You're now ready to start developing with Microsoft Graph Toolkit! The following guides are available to help you get started:
Feedback
Submit and view feedback for