'Where are the TypeScript type declarations for Sign in With Google (GSI) library?
I'm implementing "Sign in with Google" using the Google "GSI" library. My application uses Next.js and TypeScript, so I'm looking for:
- An
npm
package including the GSI client library. - TypeScript type declarations for the GSI client library.
I haven't been able to find either of these: I only see a script to load from https://accounts.google.com/gsi/client
, and an informal API reference here.
Where can I find the GSI library and type declarations on npm?
Solution 1:[1]
Types are at @types/google-one-tap
and can be used like so:
declare global {
const google: typeof import('google-one-tap');
}
I don't know where to find the actual library on npm, though.
Solution 2:[2]
- npm package for
accounts.google.com/gsi/client
is not exist, at least yet. The only way of using it is via script tag. - In addition to jameshfisher answer there are also @types/google.accounts.
Both google-one-tap
or google.accounts
can be added to tsconfig types.
tsconfig.json
"types": ["google-one-tap", "google.accounts"]
Solution 3:[3]
These type declarations are now available on npm! (via DefinitelyTyped)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | ???? ??????? |
Solution 3 | Michael McGreal |