Laravel Google ReCaptcha V3

Hafiq Iqmal
5 min readJul 19, 2022

Implement Google ReCaptcha v3 in Laravel

What is Google’s ReCaptcha?

Google ReCaptcha is a Turing test system to protect a website or app from fraud and abuse without creating friction with the program. ReCaptcha uses advanced risk analysis and adaptive challenges to keep malicious software from engaging in abusive activities on your websites and applications

By implementing ReCaptcha, websites are protected from unwanted robot scripting. Users can continue to use the website or application such as making purchases, viewing pages or creating accounts and users who are unable to complete challenges will not be able to continue and will be blocked.

Why using V3?

ReCaptcha v3 will never interrupt your users, so you can run it whenever you like without affecting conversion. ReCaptcha works best when it has the most context about interactions with your site which comes from seeing both legitimate and abusive behaviour. For this reason, it is recommend including ReCaptcha verification on forms or actions as well as in the background of pages for analytics.

Implement in Laravel

Well, in this experiment we will try to add Google ReCaptcha V3 to a login form without using any composer captcha package.

Here are the steps for V3:

  1. Create a reCaptcha V3 account
  2. Add keys to config file
  3. Implement reCaptcha scripting at Login page
  4. Create a Laravel Rule
  5. Add Validation rule to Login logic
  6. Testing and validation

Lets get started

Create a reCaptcha account

In this step we need to set google site key and secret key. If you don’t have it, we must first register a new site at this link before we can use Google ReCaptcha.

Skip this step if you already create one.

Hafiq Iqmal

Tech Lead Developer | Software Engineer | Laravel Enthusiasts | CTF Newbie | Medium writer | UiTM Alumni | Husband | Proud father of a beautiful daughter