Share via

“SDK not initialized” error?

Mattison Zhabrea 100 Reputation points
2026-03-28T08:18:57.19+00:00

I’m developing a custom Microsoft Teams tab using the Teams JavaScript SDK. The app loads correctly in a browser, but inside the Teams client it fails with an error indicating that the Teams SDK is not initialized.

The initialization code is in place, but the issue appears intermittently depending on the environment.

Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs

0 comments No comments

1 answer

Sort by: Most helpful
  1. Steven-N 24,600 Reputation points Microsoft External Staff Moderator
    2026-03-28T08:59:30.5566667+00:00

    Hi Mattison Zhabrea

    As far as I know, the intermittent failure of the Teams JavaScript SDK initialization typically stems from a race condition where the application logic attempts to invoke SDK methods before the asynchronous initialization process has reached a completed state.

    This behavior is often more pronounced in the Teams Desktop client than in a standard browser due to the specific security and lifecycle management requirements of the embedded WebView2 environment, which requires a strictly sequenced handshake between the tab and the host.

    Given this, to address this issue, ensure that the Microsoft Teams SDK is initialized synchronously and as early as possible in your application lifecycle. Specifically, microsoftTeams.app.initialize() (or app.initialize() for SDK v2.x) must be awaited before any other Teams SDK APIs are invoked. All subsequent SDK calls should be gated behind a successful initialization to avoid race conditions or undefined behavior.

    In addition, kindly confirm that your manifest.json is correctly configured. All required host URLs and authentication endpoints must be explicitly listed in the validDomains array; otherwise, the Teams host may block the SDK initialization request.

    For example:

    import * as microsoftTeams from "@microsoft/teams-js";
     
    async function runTeamsApp() {
        try {
            await microsoftTeams.app.initialize();
            // It is now safe to call other SDK methods
            const context = await microsoftTeams.app.getContext();
            console.log("App initialized successfully", context);
        } catch (error) {
            console.error("Failed to initialize Teams SDK:", error);
        }
    }
     
    runTeamsApp();
    

    You can read here for more information:

    Teams JavaScript client library

    Microsoft 365 app manifest schema reference

    Hope my answer will help you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".   

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.