
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
angular-google-recaptcha
Advanced tools
Google's reCAPTCHA is an awesome, UX-friendly way of ensuring that the users who are submitting your forms are actually humans.
Angular has fantastic built in forms functionality which makes it easy to write powerful custom components and validation logic.
This library makes it effortless to combine them!
If you ever need to reference the full reCAPTCHA docs you can find them here: reCAPTCHA docs
Head over to the command line and use your favourite package manager to install and save it as a dependency:
E.g.
npm install --save angular-google-recaptcha
or
yarn add angular-google-recaptcha
Head over to:
https://www.google.com/recaptcha/admin#list
...and register your site.
Once you have done that, a "site key" will have been generated for you. You need to find this and copy it to you clipboard as it will be important in the next step!
forRoot
convention on the NgModule
which the library exposes.E.g.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { RecaptchaModule } from 'angular-google-recaptcha';
@NgModule({
imports: [
BrowserModule,
ReactiveFormsModule,
RecaptchaModule.forRoot({
siteKey: 'YOUR_SITE_KEY_HERE',
}),
],
bootstrap: [AppComponent]
})
export class AppModule { }
As you might expect, you need to be using the @angular/forms
package (either the FormsModule
or ReactiveFormsModule
) within your project, otherwise this library will have nothing to hook into.
<recaptcha>
component!E.g. For reactive forms
import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component({
selector: 'app',
template: `
<recaptcha
[formControl]="myRecaptcha"
(scriptLoad)="onScriptLoad()"
(scriptError)="onScriptError()"
></recaptcha>
`
})
export class AppComponent {
myRecaptcha = new FormControl(false);
onScriptLoad() {
console.log('Google reCAPTCHA loaded and is ready for use!')
}
onScriptError() {
console.log('Something went long when loading the Google reCAPTCHA')
}
}
E.g. For template-driven forms
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `
<recaptcha
[(ngModel)]="myRecaptcha"
(scriptLoad)="onScriptLoad()"
(scriptError)="onScriptError()"
></recaptcha>
`
})
export class AppComponent {
myRecaptcha: boolean
onScriptLoad() {
console.log('Google reCAPTCHA loaded and is ready for use!')
}
onScriptError() {
console.log('Something went long when loading the Google reCAPTCHA')
}
}
FAQs
Easily use Google's reCAPTCHA within your Angular forms
The npm package angular-google-recaptcha receives a total of 271 weekly downloads. As such, angular-google-recaptcha popularity was classified as not popular.
We found that angular-google-recaptcha demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.