First off, we need to register our site in Google reCAPTCHA Admin and gain usage keys. When you add your site, also add localhost in the list of domains, this will allow you to use the same key for development.

Google reCAPTCHA admin console

Once you submit these details, you should see two keys generated for your domain. One is the SITE KEYwhich is used in the front-end and the other is the SECRET KEYfor usage in the server.

Front-End Setup

The front-end setup is pretty simple. Choose the page in which you want to implement reCAPTCHA, in my case I have a contact form on a page.

The below code shows a contact form with a hidden input named recaptcha (it can be any name). Then at the end of that page add the reCAPTCHA’s JS library and once it’s ready we get a token and set it to the recaptcha input.

Front-end setup

Backend Setup

Backend Setup

#web dev #php tutorial #api integration #laravel tutorial #recaptcha #web applications

Adding Google reCAPTCHA v3 to Your Laravel App
2.35 GEEK