if you are adding a static page , add this in your code await microsoftTeams.app.initialize(); and the error will go.. I was going tru the same error and it is fixed with this. Dont forget to include this also https://res.cdn.office.net/teams-js/2.30.0/js/MicrosoftTeams.min.js