I am using Next.js 12.1.5 to build a website, the client wants the form responses on the website to be sent directly to her email, so I am using a library EmailJS. EmailJS has a send method to send the form data, and you have to enter 3 string parameters to that method which are secret keys. This code is running on the client side so I have prefixed all my .env variables with NEXT_PUBLIC. It is loading the variables fine, I am just using typescript and get a type error that the .env variables are of type string | undefined and I need to pass a string. Is there any workaround other than just making the file a .js file?

I have followed multiple questions on here and still don't have a solution.

0

There are 0 best solutions below