This was surprisingly annoying to figure out.
I used this Google API documentation for vanilla JS, but it was a lot more trouble than I expected to get it working in a TypeScript React project.
Long story short, you need to install:
- gapi-script
- @types/gapi
- types/gapi.auth2
For some architectural reason it seems the gapi npm package can't just be import
ed into the .tsx file.
I think you're correct and I had to add a .d.ts file containing:
declare module "gapi-script";
I don't have time to test it out now but if that works for you, would you let me know?
Best of luck.