We have already introduced you to some new features of our Smarter Navigation in the last blog post. Among them were new configuration options for the nodes in the navigation, such as setting your own icons and colors. With the new version of Smarter Navigation , another very useful functionality has been added. In this article, we will introduce you to the new feature of OneDrive synchronization of several SharePoint document libraries, which you can do directly in the navigation.

OneDrive synchronization of multiple SharePoint libraries

In SharePoint, you have the option of synchronizing document libraries with OneDrive. To do this, you have to navigate to the library and can synchronize it with OneDrive via a button. However, if you want to synchronize several libraries, this can quickly become time-consuming and tedious. This is where our new feature comes in handy, as it allows you to select multiple libraries at once and sync them with OneDrive in one step.

Frontend implementation OneDrive synchronization

For the new feature of a OneDrive synchronization, we display a button “Open with OneDrive” directly in the navigation. If the user clicks on this button, we switch to OneDrive synchronization mode. The user then has the option of selecting multiple document libraries via a checkbox for OneDrive synchronization. After the user has selected all the desired libraries, he can click on the “Synchronize selection” button. We then synchronize all selected document libraries with OneDrive in one step. This has the great advantage that the user does not have to synchronize each library individually with OneDrive.

Our app requires the graph permission “Files.ReadWrite.All” for the feature, which must be approved by an administrator. Only after approval will we display the “Open with OneDrive” button for the new feature.

Synchronization via API call using AadHttpClient

For synchronization with OneDrive of the selected libraries, we use the AadHttpClient from SPFx. We create this client via a factory with the URL for the specific endpoint: https://yourcompany-my.sharepoint.com

const aadHttpClientUrl = window.location.origin.replace(".sharepoint.com", "-my.sharepoint.com");
var aadHttpClient = await this.context.aadHttpClientFactory.getClient(aadHttpClientUrl);

Because the AadHttpClient stores the authentication token in the cookies, they must be allowed for optimal use of Smarter Navigation. If cookies are not allowed, this can lead to the page being automatically reloaded several times. The problem is due to a bug in the NPM package @microsoft/sp-http and we have already submitted a ticket. As soon as the error has been fixed, we will of course install an update of our Smarter Navigation so that there is no longer a problem here.

With this AadHttpClient we make an API call to synchronize the libraries with OneDrive:

public async syncListItemToOneDrive(item: OneDriveItem): Promise<boolean> {
        const body = {
            name: item.title,
            remoteItem: {
                sharepointIds: {
                    listId: item.id,
                    listItemUniqueId: "root",
                    siteId: this.siteId,
                    siteUrl: this.siteUrl,
                    webId: this.webId,
            "@microsoft.graph.conflictBehavior": "rename"

        const result = await this.aadHttpClient.post(`${this.aadHttpClientUrl}/_api/v2.1/drives/me/items/root/children`,
                body: JSON.stringify(body),
                headers: {
                    "content-type": "application/json"

We hope we were able to give you a good insight into the OneDrive synchronization of document libraries directly in the Smarter Navigation with this article.

Have we aroused your interest and would you like more information about our Smarter Navigation? Then feel free to contact us. You can also subscribe to our newsletter – then you will be the first to know about news:


Never miss any offers or innovations?

Sign up for our newsletter and be the first to learn about exciting new products and topics around Microsoft SharePoint, Teams, and Co.

You can unsubscribe at any time. Your data will only be used to send our newsletter and will not be passed on to third parties. Additional information on the protection of your data can be found in our privacy policy.