Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-recaptcha

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-recaptcha

Angular component for Google reCAPTCHA

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
142K
decreased by-1.6%
Maintainers
1
Weekly downloads
 
Created

What is ng-recaptcha?

The ng-recaptcha package is an Angular library that provides a simple way to integrate Google's reCAPTCHA into Angular applications. It supports both reCAPTCHA v2 and v3, allowing developers to add CAPTCHA verification to forms and other interactive elements to enhance security.

What are ng-recaptcha's main functionalities?

Basic reCAPTCHA v2 Integration

This feature allows you to integrate the basic reCAPTCHA v2 into your Angular application. The component listens for the resolved event to handle the CAPTCHA response.


import { Component } from '@angular/core';

@Component({
  selector: 'app-recaptcha',
  template: '<re-captcha (resolved)="resolved($event)" siteKey="your-site-key"></re-captcha>'
})
export class RecaptchaComponent {
  resolved(captchaResponse: string) {
    console.log(`Resolved captcha with response: ${captchaResponse}`);
  }
}

reCAPTCHA v3 Integration

This feature demonstrates how to use reCAPTCHA v3, which does not require user interaction. Instead, it generates a token based on user behavior, which can be used for verification.


import { Component } from '@angular/core';
import { ReCaptchaV3Service } from 'ng-recaptcha';

@Component({
  selector: 'app-recaptcha-v3',
  template: '<button (click)="executeAction()">Execute reCAPTCHA v3</button>'
})
export class RecaptchaV3Component {
  constructor(private recaptchaV3Service: ReCaptchaV3Service) {}

  executeAction() {
    this.recaptchaV3Service.execute('importantAction').subscribe((token) => {
      console.log(`Token received: ${token}`);
    });
  }
}

Invisible reCAPTCHA

This feature shows how to implement invisible reCAPTCHA, which is triggered programmatically rather than by user interaction. This is useful for forms where you want to minimize user friction.


import { Component } from '@angular/core';

@Component({
  selector: 'app-invisible-recaptcha',
  template: '<re-captcha (resolved)="resolved($event)" siteKey="your-site-key" size="invisible"></re-captcha><button (click)="executeCaptcha()">Submit</button>'
})
export class InvisibleRecaptchaComponent {
  resolved(captchaResponse: string) {
    console.log(`Resolved captcha with response: ${captchaResponse}`);
  }

  executeCaptcha() {
    // Trigger the invisible reCAPTCHA
  }
}

Other packages similar to ng-recaptcha

Keywords

FAQs

Package last updated on 01 May 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc