Option 1: Casting
The simple solution is to just cast the environment variables to strings like below. This will work fine if you know your environment variables are defined. However you will get errors if you every in the future forget to set them.
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
})
Option 2: Type narrowing
You can make sure that your env variables are defined before accessing them. This can get very repetitive though. Typescript will now know that are not undefined are this code block. You have the same problem as in option 1 though pretty much.
if (
process.env.GOOGLE_CLIENT_ID === undefined ||
process.env.GOOGLE_CLIENT_SECRET == undefined
) {
throw new Error('Invalid env vars');
}
Option 3: Typed env vars
This is in my opinion the best option. I can strongly recommend the package t3-env. Then you will have access to type safe environment variables.