Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ng-recaptcha-2

LakhveerChahal105.7kMIT16.0.1TypeScript support: included

Angular component for Google reCAPTCHA for Angular v18 and onwards

angular, recaptcha, angular-recaptcha, ng-recaptcha, ng-recaptcha-2, angular-20

readme

Angular component for Google reCAPTCHA

ng-recaptcha-2 npm version

Parent project (ng-recaptcha)

MIT licensed Build Status Coverage Status NPM downloads

A simple, configurable, easy-to-start component for handling reCAPTCHA v2 and v3.

"Buy Me A Coffee"

Table of contents

  1. Installation
  2. Basic Usage
  3. Working with @angular/forms
  4. API
  5. Angular version compatibility
  6. Examples

Installation

The easiest way is to install through yarn or npm:

yarn add ng-recaptcha-2
npm i ng-recaptcha-2 --save

Basic Usage (see in action)

The below applies to reCAPTCHA v2, for basic usage with reCAPTCHA v3 scroll down to here.

To start with, you need to import the RecaptchaModule (more on that later):

// app.module.ts
import { RecaptchaModule } from "ng-recaptcha-2";
// if you need forms support:
// import { RecaptchaModule, RecaptchaFormsModule } from 'ng-recaptcha-2';
import { BrowserModule } from "@angular/platform-browser";
import { MyApp } from "./app.component.ts";

@NgModule({
  bootstrap: [MyApp],
  declarations: [MyApp],
  imports: [
    BrowserModule,
    RecaptchaModule,
    // RecaptchaFormsModule, // if you need forms support
  ],
})
export class MyAppModule {}

Once you have done that, the rest is simple:

// app.component.ts
import { Component } from "@angular/core";

@Component({
  selector: "my-app",
  template: `<re-captcha (resolved)="resolved($event)" siteKey="YOUR_SITE_KEY"></re-captcha>`,
})
export class MyApp {
  resolved(captchaResponse: string) {
    console.log(`Resolved captcha with response: ${captchaResponse}`);
  }
}
// main.ts
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { MyAppModule } from "./app.module.ts";

platformBrowserDynamic().bootstrapModule(MyAppModule);

reCAPTCHA v3 Usage (see in action)

reCAPTCHA v3 introduces a different way of bot protection. To work with v3 APIs, ng-recaptcha provides a service (as opposed to a component). To start with, you need to import the RecaptchaV3Module and provide your reCAPTCHA v3 site key using RECAPTCHA_V3_SITE_KEY injection token:

import { BrowserModule } from "@angular/platform-browser";
import { RECAPTCHA_V3_SITE_KEY, RecaptchaV3Module } from "ng-recaptcha-2";

import { MyApp } from "./app.component.ts";

@NgModule({
  bootstrap: [MyApp],
  declarations: [MyApp],
  imports: [BrowserModule, RecaptchaV3Module],
  providers: [{ provide: RECAPTCHA_V3_SITE_KEY, useValue: "<YOUR_SITE_KEY>" }],
})
export class MyAppModule {}

In order to execute a reCAPTCHA v3 action, import the ReCaptchaV3Service into your desired component:

import { ReCaptchaV3Service } from 'ng-recaptcha-2';

@Component({
  selector: 'recaptcha-demo',
  template: `
    <button (click)="executeImportantAction()">Important action</button>
  `,
})
export class RecaptchaV3DemoComponent {
  constructor(
    private recaptchaV3Service: ReCaptchaV3Service,
  ) {
  }

  public executeImportantAction(): void {
    this.recaptchaV3Service.execute('importantAction')
      .subscribe((token) => this.handleToken(token));
  }

As always with subscriptions, please don't forget to unsubscribe.

❗️ Important note: If your site uses both v2 and v3, then you should always provide RECAPTCHA_V3_SITE_KEY (even in modules that only rely on v2 functionality). This will prevent bugs in your code by allowing ng-recaptcha to follow reCAPTCHA development guidelines properly (this one in particular).

A more advanced v3 usage scenario includes listening to all actions and their respectively emitted tokens. This is covered later on this page.

Playground

You can also play with this Stackblitz demo to get a feel of how this component can be used.

Working with @angular/forms

There are two modules available for you:

import { RecaptchaModule, RecaptchaFormsModule } from "ng-recaptcha-2";

If you want your <re-captcha> element to work correctly with [(ngModel)] directive, you need to import the RecaptchaFormsModule into your application module (pretty much like with Angular own '@angular/forms' module).

API

Input Options

The component supports this options:

  • siteKey
  • theme
  • type
  • size
  • tabIndex
  • badge

They are all pretty well described either in the reCAPTCHA docs, or in the invisible reCAPTCHA docs, so I won't duplicate it here.

One additional option that component accepts is errorMode. You can learn more about it in the Handling errors section below.

Besides specifying these options on the component itself, you can provide a global <re-captcha> configuration - see Configuring the component globally section below.

Events

  • resolved(response: string). Occurs when the captcha resolution value changed. When user resolves captcha, use response parameter to send to the server for verification. This parameter is equivalent to calling grecaptcha.getResponse.

    If the captcha has expired prior to submitting its value to the server, the component will reset the captcha, and trigger the resolved event with response === null.

  • errored(errorDetails: RecaptchaErrorParameters). Occurs when reCAPTCHA encounters an error (usually a connectivity problem) if and only if errorMode input has been set to "handled". errorDetails is a simple propagation of any arguments that the original error-callback has provided, and is documented here for the purposes of completeness and future-proofing. This array will most often (if not always) be empty. A good strategy would be to rely on just the fact that this event got triggered, and show a message to your app's user telling them to retry.

Methods

  • reset(). Performs a manual captcha reset. This method might be useful if your form validation failed, and you need the user to re-enter the captcha.
  • execute(). Executes the invisible recaptcha. Does nothing if component's size is not set to "invisible". See Invisible reCAPTCHA developers guide for more information.

Angular version compatibility

ng-recaptcha-2 version Supported Angular versions
16.x.x 20.x.x
15.x.x 19.x.x
14.x.x 18.x.x
ng-recaptcha version Supported Angular versions
13.x.x 17.x.x
12.x.x 16.x.x
11.x.x 15.x.x
10.x.x 14.x.x
9.x.x 13.x.x
8.x.x 12.x.x
7.x.x 11.x.x
⬆️ Starting with ng-recaptcha@7, only one version of Angular will be supported
6.x.x 6.x.x || 7.x.x || 8.x.x || 9.x.x || 10.x.x
5.x.x 6.x.x || 7.x.x || 8.x.x
4.x.x 6.x.x || 7.x.x
3.x.x 4.x.x || 5.x.x
2.x.x 2.x.x || 4.x.x
1.x.x 2.x.x

Examples

Configuring the component globally (see in action)

Some properties are global - including siteKey, size, and others. You can provide them at the module-level using the RECAPTCHA_SETTINGS provider:

import { RECAPTCHA_SETTINGS, RecaptchaSettings } from "ng-recaptcha-2";

@NgModule({
  providers: [
    {
      provide: RECAPTCHA_SETTINGS,
      useValue: { siteKey: "<YOUR_KEY>" } as RecaptchaSettings,
    },
  ],
})
export class MyModule {}

Global properties can be overridden on a case-by-case basis - the values on the <re-captcha> component itself take precedence over global settings.

Specifying a different language (see in action)

<re-captcha> supports various languages. By default recaptcha will guess the user's language itself (which is beyond the scope of this lib). But you can override this behavior and provide a specific language to use by setting the "hl" search param in the onBeforeLoad hook. Note, that the language setting is global, and cannot be set on a per-captcha basis.

A good way to synchronize reCAPTCHA language with the rest of your application is relying on LOCALE_ID value like so:

import { LOCALE_ID } from "@angular/core";
import { RECAPTCHA_LOADER_OPTIONS } from "ng-recaptcha-2";

@NgModule({
  providers: [
    {
      provide: RECAPTCHA_LOADER_OPTIONS,
      useFactory: (locale: string) => ({
        onBeforeLoad(url) {
          url.searchParams.set("hl", locale);

          return { url };
        },
      }),
      deps: [LOCALE_ID],
    },
  ],
})
export class MyModule {}

Alternatively, a specific language can be provided like so:

import { RECAPTCHA_LOADER_OPTIONS } from "ng-recaptcha-2";

@NgModule({
  providers: [
    {
      provide: RECAPTCHA_LOADER_OPTIONS,
      useValue: {
        onBeforeLoad(url) {
          url.searchParams.set("hl", "fr"); // use French language

          return { url };
        },
      },
    },
  ],
})
export class MyModule {}

You can find the list of supported languages in reCAPTCHA docs.

Handling errors

Sometimes reCAPTCHA encounters an error, which is usually a network connectivity problem. It cannot continue until connectivity is restored. By default, reCAPTCHA lets the user know that an error has happened (it's a built-in functionality of reCAPTCHA itself, and this lib is not in control of it). The downside of such behavior is that you, as a developer, don't get notified about this in any way. Opting into such notifications is easy, but comes at a cost of assuming responsibility for informing the user that they should retry. Here's how you would do this:

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

@Component({
  selector: "my-app",
  template: `<re-captcha (resolved)="resolved($event)" (errored)="errored($event)" errorMode="handled"></re-captcha>`,
})
export class MyApp {
  resolved(captchaResponse: string) {
    console.log(`Resolved captcha with response: ${captchaResponse}`);
  }

  errored() {
    console.warn(`reCAPTCHA error encountered`);
  }
}

You can see this in action by navigating to either basic example demo or invisible demo and trying to interact with reCAPTCHA after setting the network to "Offline".

The errorMode input has two possible values -- "handled" and "default", with latter being the default as the name suggests. Not specifying errorMode, or setting it to anything other than "handled" will not invoke your (errored) callback, and will instead result in default reCAPTCHA functionality.

The (errored) callback will propagate all of the parameters that it receives from grecaptcha['error-callback'] (which might be none) as an array.

Loading the reCAPTCHA API by yourself (see in action)

By default, the component assumes that the reCAPTCHA API loading will be handled by the RecaptchaLoaderService. However, you can override that by providing your instance of this service to the Angular DI.

The below code snippet is an example of how such a provider can be implemented.

TL;DR: there should be an Observable that eventually resolves to a grecaptcha-compatible object (e.g. grecaptcha itself).

<script src="https://www.google.com/recaptcha/api.js?render=explicit&amp;onload=onloadCallback"></script>

<script>
  // bootstrap the application once the reCAPTCHA api has loaded
  function onloadCallback() {
    System.import("app").catch(function (err) {
      console.error(err);
    });
  }
</script>
import { RecaptchaLoaderService } from "ng-recaptcha-2";

@Injectable()
export class PreloadedRecaptchaAPIService {
  public ready: Observable<ReCaptchaV2.ReCaptcha>;

  constructor() {
    let readySubject = new BehaviorSubject<ReCaptchaV2.ReCaptcha>(grecaptcha);
    this.ready = readySubject.asObservable();
  }
}

@NgModule({
  providers: [
    {
      provide: RecaptchaLoaderService,
      useValue: new PreloadedRecaptchaAPIService(),
    },
  ],
})
export class MyModule {}

Usage with required in forms (see in action)

It's very easy to put <re-captcha> in an Angular form and have it required - just add the required attribute to the <re-captcha> element. Do not forget to import RecaptchaFormsModule from 'ng-recaptcha-2'!

@Component({
  selector: "my-form",
  template: ` <form>
    <re-captcha [(ngModel)]="formModel.captcha" name="captcha" required siteKey="YOUR_SITE_KEY"></re-captcha>
  </form>`,
})
export class MyForm {
  formModel = new MyFormModel();
}

A similar approach can be taken for reactive forms:

@Component({
  selector: "my-reactive-form",
  template: `
    <form [formGroup]="reactiveForm">
      <re-captcha formControlName="recaptchaReactive"></re-captcha>
      <button [disabled]="reactiveForm.invalid">Submit</button>
    </form>
  `,
})
export class MyReactiveForm {
  reactiveForm: FormGroup;

  ngOnInit() {
    this.reactiveForm = new FormGroup({
      recaptchaReactive: new FormControl(null, Validators.required),
    });
  }
}

Working with invisible reCAPTCHA (see in action)

Working with invisible reCAPTCHA is almost the same as with regular one. First, you need to provide the right size:

<re-captcha size="invisible" ...></re-captcha>

You will also need to invoke the "execute()" method manually. This can be done by either obtaining a reference to RecaptchaComponent via @ViewChild(), or by using inline template reference:

<re-captcha #captchaRef="reCaptcha" ...></re-captcha>
...
<button (click)="captchaRef.execute()">Submit</button>

Normally you would only submit a form when recaptcha response has been received. This can be achieved by reacting to (resolved) event and invoking submit logic when the captcha response is truthy (this will not try to submit the form when recaptcha response has expired). A sample implementation would look like this:

@Component({
  selector: "my-form",
  template: ` <form>
    <re-captcha
      #captchaRef="reCaptcha"
      siteKey="YOUR_SITE_KEY"
      size="invisible"
      (resolved)="$event && submit($event)"
    ></re-captcha>
    <button (click)="captchaRef.execute()">Submit</button>
  </form>`,
})
export class MyForm {
  public submit(captchaResponse: string): void {
    this.http.post({
      captcha: captchaResponse,
      /* ... */
    });
  }
}

Resizing

Making reCAPTCHA responsive is sometimes necessary, especially when working with mobile devices. You can use css-transforms to achieve that as in this StackOverflow answer, which is also ell-described in this blog post. You can also take a look at a live example of how this might be implemented. This boils down to

<div style="transform:scale(0.7);transform-origin:0;">
  <re-captcha></re-captcha>
</div>

SystemJS configuration

To configure the package to work with SystemJS, you would configure it approximately like that (assuming you've installed ng-recaptcha-2 using npm):

// SystemJS config file
(function () {
  System.config({
    paths: {
      "npm:": "/node_modules/",
    },
    map: {
      "ng-recaptcha-2": "npm:ng-recaptcha-2",
    },
    packages: {
      "ng-recaptcha-2": { main: "./index.js" },
    },
  });
})();

Loading from a different location

Since "google.com" domain might be unavailable in some countries, reCAPTCHA core team has a solution for that - using "recaptcha.net" domain. You can configure the component to use that by using the onBeforeLoad hook of RECAPTCHA_LOADER_OPTIONS, for example:

import { RECAPTCHA_LOADER_OPTIONS } from "ng-recaptcha-2";

@NgModule({
  providers: [
    {
      provide: RECAPTCHA_LOADER_OPTIONS,
      useValue: {
        onBeforeLoad(_url) {
          return {
            url: new URL("https://www.recaptcha.net/recaptcha/api.js"), // use recaptcha.net script source for some of our users
          };
        },
      },
    },
  ],
})
export class MyModule {}

Specifying nonce for Content-Security-Policy

Per reCAPTCHA FAQ on CSP, the recommended approach for that is to supply nonce to the script tag. This is possible by providing the nonce as part of the onBeforeLoad hook of RECAPTCHA_LOADER_OPTIONS, for example

import { RECAPTCHA_LOADER_OPTIONS } from "ng-recaptcha-2";

@NgModule({
  providers: [
    {
      provide: RECAPTCHA_LOADER_OPTIONS,
      useValue: {
        onBeforeLoad(_url) {
          return {
            url,
            nonce: "<YOUR_NONCE_VALUE>",
          };
        },
      },
    },
  ],
})
export class MyModule {}

Listening for all actions with reCAPTCHA v3

More often than not you will need to only get a reCAPTCHA token with the action the user is currently taking, and submit it to the backend at that time. However, having a single listener for all events will be desirable.

There is an Observable exactly for that purpose: ReCaptchaV3Service.onExecute. It emits a value every time a token is received from reCAPTCHA. The shape of payload it operates on is defined via OnExecuteData interface:

interface OnExecuteData {
  action: string;
  token: string;
}

where action is the name of the action that has been executed, and token is what reCAPTCHA v3 provided when executing that action.

Here's how you would potentially set this up:

import { OnExecuteData, ReCaptchaV3Service } from "ng-recaptcha-2";

@Component({
  selector: "my-component",
  templateUrl: "./v3-demo.component.html",
})
export class MyComponent implements OnInit, OnDestroy {
  private subscription: Subscription;

  constructor(private recaptchaV3Service: ReCaptchaV3Service) {}

  public ngOnInit() {
    this.subscription = this.recaptchaV3Service.onExecute.subscribe((data: OnExecuteData) => {
      this.handleRecaptchaExecute(data.action, data.token);
    });
  }

  public ngOnDestroy() {
    if (this.subscription) {
      this.subscription.unsubscribe();
    }
  }
}

There are a couple things to keep in mind:

  • onExecute will trigger for all actions. If you only need to bulk-process some actions, and not others - you will have to apply filtering yourself.
  • onExecute observable will provide you with all the events emitted after you have subscribed to it - it doesn't keep references to the previously emitted actions. So make sure you add such a subscription as early in your code as you feel is necessary.
  • onExecute does not emit anything for when a grecaptcha error occurs. Use onExecuteError Observable for that.

Loading reCAPTCHA keys asynchronously

If your use-case needs to load the reCAPTCHA v2/v3 key from the backend (as opposed to specifying it in-code during build time), the Angular-idiomatic way to do that is by relying on APP_INITIALIZER. You can find an example of how this could look like below, and you can also consult the source code for the demo site.

// config.service.ts
import { Injectable } from "@angular/core";

@Injectable({
  providedIn: "root",
})
export class ConfigService {
  public recaptchaSiteKeyV2: string | null = null;
  public recaptchaSiteKeyV3: string | null = null;

  public async loadConfig(): Promise<void> {
    const { siteKeyV2, siteKeyV3 } = await fetchConfig(/* some API call */);
    this.recaptchaSiteKeyV2 = siteKeyV2;
    this.recaptchaSiteKeyV3 = siteKeyV3;
  }
}

// app.module.ts
import { APP_INITIALIZER, NgModule } from "@angular/core";
import { RECAPTCHA_SETTINGS, RecaptchaSettings, RECAPTCHA_V3_SITE_KEY } from "ng-recaptcha-2";

import { ConfigService } from "./config.service";

function appLoadFactory(config: ConfigService) {
  return () => config.loadConfig().then(() => console.log(`config resolved`, config));
}

@NgModule({
  providers: [
    {
      provide: RECAPTCHA_V3_SITE_KEY,
      useFactory: (config: ConfigService) => {
        return config.recaptchaSiteKeyV3;
      },
      deps: [ConfigService],
    },
    {
      provide: RECAPTCHA_SETTINGS,
      useFactory: (config: ConfigService): RecaptchaSettings => {
        return { siteKey: config.recaptchaSiteKeyV2 };
      },
      deps: [ConfigService],
    },
    {
      provide: APP_INITIALIZER,
      useFactory: appLoadFactory,
      deps: [ConfigService],
      multi: true,
    },
  ],
})
export class AppModule {}

Hiding reCAPTCHA badge

To start with, this is not strictly under ng-recaptcha-2 library control. However, there is a way of doing so (albeit subject to certain conditions). Please refer to the FAQ section of reCAPTCHA documentation to get an idea of what you're required to do.

changelog

16.0.1 (2025-06-07)

15.0.3 (2025-03-26)

Bug Fixes

  • build: fix AoT builds (921be50), closes #57 #65
  • component-v3: fix a potential metadata error in v3 service (ed885b5)
  • component: catch and propagate grecaptcha errors, closes #175 (075edd0)
  • component: correct type when using strict mode (a687d13), closes #211
  • component: correctly emit resolved event (25d4246)
  • component: correctly reset captcha during ngOnDestroy (b31d57f), closes #12
  • component: delay invisible recaptcha execution until it's rendered (99292b7), closes #127
  • component: emit resolved(null) event when recaptcha expires (491d99a), closes #11
  • component: ensure that component is destroyed safely (1e51d56), closes #46
  • component: fix a potential error during recaptcha rendering (1c395b5)
  • component: fix custom languages for reCAPTCHA v3 (a2b145d), closes #174
  • component: fix server-side rendering (7a5bc6c), closes #34 /github.com/angular/angular/blob/master/CHANGELOG.md#features-20
  • component: fix the injection error when using slandalone RecaptchaV3Module (c93b99c)
  • component: handle id input parameter correctly (b578fe5)
  • component: handle top-level execute errors for reCAPTCHA v3 (c7d02ce), closes #194
  • component: improve reCAPTCHA v2 and v3 interoperability (79fc85b), closes #152
  • component: mark forRoot() method as deprecated (dea31e5)
  • component: Replace OpaqueToken with InjectionToken (2b7db9b)
  • component: reset form-bound captcha value after component destruction (9e5c5e7), closes #201
  • component: reset form-bound captcha value after component destruction (0e550c4), closes #201
  • component: reset the captcha when the component is destroyed (e1441c8), closes #10
  • component: set CSP nonce as attribute (abcb9a6)
  • component: unblock protractor tests after <re-captcha> destruction (a5f2fe9)
  • component: use ElementRef to access component's native element (d3a8409), closes #48 #68
  • demo: re-add a missing systemjs config file (b51694a)
  • module: Adding the value accessor directive to the forms barrel, which was missing. (ad73e2e)
  • package: convert the README.md file back to a proper symlink (e0c5c99)
  • package: fix publishing empty package (e4685fe)
  • package: make [@types](https://github.com/types)/grecaptcha a non-optional dependency (bc5ad51), closes #205
  • rxjs: change import of of operator (3e0bda6), closes #95

Features

  • component: deprecate error output in favor of errored (6b002bb)
  • component: add exportAs annotation (3e2e217)
  • component: add a new RECAPTCHA_LOADER_OPTIONS injection token as a way of manipulating script load parameters (such as base URL, language, trusted types, WAF, etc) (b3c7213)
  • component: Add Angular 11 support (918fe90)
  • component: add support for badge property (5a16430), closes #30
  • component: add support for invisible reCAPTCHA (c19489d), closes #18
  • component: add support for reCAPTCHA v3 (4a083c6), closes #129
  • component: add the ability to handle reCAPTCHA errors (80c9e6e), closes #199
  • component: add the ability to provide nonce to the script tag (8f55b19), closes #100
  • component: add the ability to specify component props globally (d9c5f55), closes #45
  • component: adjust dependencies for Angular 6 support (736c7ae)
  • component: allow to specify a base url for loading recaptcha (df505fd), closes #101
  • component: change component and directive selectors (58a01b4)
  • component: load recaptcha script using code compatible with trusted types (88d257b), closes #304
  • component: make Angular 10.0.0 a supported peer dependency (3d7756b), closes #177
  • component: make Angular 8.0.0 a supported peer dependency (f003ff2)
  • component: make Angular 9.0.0 a supported peer dependency (98edce6), closes #168
  • component: remove deprecated forRoot method (514beaf)
  • misc: Annotating a static field with nocollapse so that we doesn't have issues closure compiler in advanced mode. (55e5932)
  • module: change the way recaptcha modules work (6e13389)
  • module: skip forRoot() when importing RecaptchaModule (7fb97fb), closes #113 #116
  • package management: add [@types](https://github.com/types)/grecaptcha as optional dependency (85fbfba)
  • package: add Angular 12 support (a212a21)
  • package: add Angular 14 support (eac6858)
  • package: add Angular 15 support (6c62634), closes #275
  • package: add Angular 16 support (77a7d1f), closes #288
  • package: add Angular 17 support (83714aa), closes #310
  • package: implement Angular Package format (71340c4)
  • package: update "[@types](https://github.com/types)/grecaptcha" optional dependency version to ^3 (e1ee7b9)
  • package: update peer dependencies to include Angular 7 (929ef7a)
  • package: update peer dependencies to include Angular v4 (b2f04e8)
  • package: upgrade to Angular 13 (af08641), closes #245

BREAKING CHANGES

  • package: - Angular v16 is no longer supported with this version. Pin ng-recaptcha to v12.x.x to retain support for a previous Angular version
  • package: - Angular v15 is no longer supported with this version. Pin ng-recaptcha to v11.x.x to retain support for a previous Angular version
  • component: Support for previous versions of Angular has been dropped. Starting from v7 only one version of Angular will be supported.
  • component: The RecaptchaModule.forRoot() method has been obsolete since v4.1.0 (since it has no longer been required). It is now removed. To migrate your code, simply use RecaptchaModule where you previously used RecaptchaModule.forRoot()
  • package: * ng-recaptcha/forms entry point has been removed. RecaptchaFormsModule and RecaptchaValueAccessorDirective should now be imported directly from ng-recaptcha
  • tslib is now a package dependency to ensure minimum possible bundle size. If your project doesn't yet have a dependency on tslib, run npm install -D tslib@^1.9.0 (or yarn add -D tslib@^1.9.0 if you use yarn)
  • component: The peer dependency for @angular/core has been bumped to ^6.0.0
  • component:
  • component: component selector changed from recaptcha to re-captcha
  • module: module handling has changed. Users of RecaptchaNoFormsModule should instead use import { RecaptchaModule } from 'ng-recaptcha'. Users of v1 RecaptchaModule should also import { RecaptchaFormsModule } from 'ng-recaptcha/forms'. SystemJS users must also re-setup module "main" file to index.js

15.0.2 (2024-12-07)

15.0.2-rc1 (2024-12-02)

15.0.1 (2024-11-22)

14.0.0 (2024-05-25)

Bug Fixes

  • build: fix AoT builds (921be50), closes #57 #65
  • component-v3: fix a potential metadata error in v3 service (ed885b5)
  • component: catch and propagate grecaptcha errors, closes #175 (075edd0)
  • component: correct type when using strict mode (a687d13), closes #211
  • component: correctly emit resolved event (25d4246)
  • component: correctly reset captcha during ngOnDestroy (b31d57f), closes #12
  • component: delay invisible recaptcha execution until it's rendered (99292b7), closes #127
  • component: emit resolved(null) event when recaptcha expires (491d99a), closes #11
  • component: ensure that component is destroyed safely (1e51d56), closes #46
  • component: fix a potential error during recaptcha rendering (1c395b5)
  • component: fix custom languages for reCAPTCHA v3 (a2b145d), closes #174
  • component: fix server-side rendering (7a5bc6c), closes #34 /github.com/angular/angular/blob/master/CHANGELOG.md#features-20
  • component: fix the injection error when using slandalone RecaptchaV3Module (c93b99c)
  • component: handle id input parameter correctly (b578fe5)
  • component: handle top-level execute errors for reCAPTCHA v3 (c7d02ce), closes #194
  • component: improve reCAPTCHA v2 and v3 interoperability (79fc85b), closes #152
  • component: mark forRoot() method as deprecated (dea31e5)
  • component: Replace OpaqueToken with InjectionToken (2b7db9b)
  • component: reset form-bound captcha value after component destruction (9e5c5e7), closes #201
  • component: reset form-bound captcha value after component destruction (0e550c4), closes #201
  • component: reset the captcha when the component is destroyed (e1441c8), closes #10
  • component: set CSP nonce as attribute (abcb9a6)
  • component: unblock protractor tests after <re-captcha> destruction (a5f2fe9)
  • component: use ElementRef to access component's native element (d3a8409), closes #48 #68
  • demo: re-add a missing systemjs config file (b51694a)
  • module: Adding the value accessor directive to the forms barrel, which was missing. (ad73e2e)
  • package: convert the README.md file back to a proper symlink (e0c5c99)
  • package: fix publishing empty package (e4685fe)
  • package: make [@types](https://github.com/types)/grecaptcha a non-optional dependency (bc5ad51), closes #205
  • rxjs: change import of of operator (3e0bda6), closes #95

Features

  • component: deprecate error output in favor of errored (6b002bb)
  • component: add exportAs annotation (3e2e217)
  • component: add a new RECAPTCHA_LOADER_OPTIONS injection token as a way of manipulating script load parameters (such as base URL, language, trusted types, WAF, etc) (b3c7213)
  • component: Add Angular 11 support (918fe90)
  • component: add support for badge property (5a16430), closes #30
  • component: add support for invisible reCAPTCHA (c19489d), closes #18
  • component: add support for reCAPTCHA v3 (4a083c6), closes #129
  • component: add the ability to handle reCAPTCHA errors (80c9e6e), closes #199
  • component: add the ability to provide nonce to the script tag (8f55b19), closes #100
  • component: add the ability to specify component props globally (d9c5f55), closes #45
  • component: adjust dependencies for Angular 6 support (736c7ae)
  • component: allow to specify a base url for loading recaptcha (df505fd), closes #101
  • component: change component and directive selectors (58a01b4)
  • component: load recaptcha script using code compatible with trusted types (88d257b), closes #304
  • component: make Angular 10.0.0 a supported peer dependency (3d7756b), closes #177
  • component: make Angular 8.0.0 a supported peer dependency (f003ff2)
  • component: make Angular 9.0.0 a supported peer dependency (98edce6), closes #168
  • component: remove deprecated forRoot method (514beaf)
  • misc: Annotating a static field with nocollapse so that we doesn't have issues closure compiler in advanced mode. (55e5932)
  • module: change the way recaptcha modules work (6e13389)
  • module: skip forRoot() when importing RecaptchaModule (7fb97fb), closes #113 #116
  • package management: add [@types](https://github.com/types)/grecaptcha as optional dependency (85fbfba)
  • package: add Angular 12 support (a212a21)
  • package: add Angular 14 support (eac6858)
  • package: add Angular 15 support (6c62634), closes #275
  • package: add Angular 16 support (77a7d1f), closes #288
  • package: add Angular 17 support (83714aa), closes #310
  • package: implement Angular Package format (71340c4)
  • package: update "[@types](https://github.com/types)/grecaptcha" optional dependency version to ^3 (e1ee7b9)
  • package: update peer dependencies to include Angular 7 (929ef7a)
  • package: update peer dependencies to include Angular v4 (b2f04e8)
  • package: upgrade to Angular 13 (af08641), closes #245

BREAKING CHANGES

  • package: - Angular v16 is no longer supported with this version. Pin ng-recaptcha to v12.x.x to retain support for a previous Angular version
  • package: - Angular v15 is no longer supported with this version. Pin ng-recaptcha to v11.x.x to retain support for a previous Angular version
  • component: Support for previous versions of Angular has been dropped. Starting from v7 only one version of Angular will be supported.
  • component: The RecaptchaModule.forRoot() method has been obsolete since v4.1.0 (since it has no longer been required). It is now removed. To migrate your code, simply use RecaptchaModule where you previously used RecaptchaModule.forRoot()
  • package: * ng-recaptcha/forms entry point has been removed. RecaptchaFormsModule and RecaptchaValueAccessorDirective should now be imported directly from ng-recaptcha
  • tslib is now a package dependency to ensure minimum possible bundle size. If your project doesn't yet have a dependency on tslib, run npm install -D tslib@^1.9.0 (or yarn add -D tslib@^1.9.0 if you use yarn)
  • component: The peer dependency for @angular/core has been bumped to ^6.0.0
  • component:
  • component: component selector changed from recaptcha to re-captcha
  • module: module handling has changed. Users of RecaptchaNoFormsModule should instead use import { RecaptchaModule } from 'ng-recaptcha'. Users of v1 RecaptchaModule should also import { RecaptchaFormsModule } from 'ng-recaptcha/forms'. SystemJS users must also re-setup module "main" file to index.js

13.2.1 (2023-11-25)

Bug Fixes

  • component: fix the injection error when using slandalone RecaptchaV3Module (c93b99c)

13.2.0 (2023-11-25)

Features

  • component: add a new RECAPTCHA_LOADER_OPTIONS injection token as a way of manipulating script load parameters (such as base URL, language, trusted types, WAF, etc) (b3c7213)

13.1.0 (2023-11-24)

Features

  • component: load recaptcha script using code compatible with trusted types (88d257b), closes #304

13.0.0 (2023-11-23)

Features

  • package: add Angular 17 support (83714aa), closes #310

BREAKING CHANGES

  • package: - Angular v16 is no longer supported with this version. Pin ng-recaptcha to v12.x.x to retain support for a previous Angular version

12.0.2 (2023-07-31)

Bug Fixes

  • component: set CSP nonce as attribute (abcb9a6)

12.0.1 (2023-05-24)

Bug Fixes

  • package: convert the README.md file back to a proper symlink (e0c5c99)

12.0.0 (2023-05-24)

Features

  • package: add Angular 16 support (77a7d1f), closes #288

BREAKING CHANGES

  • package: - Angular v15 is no longer supported with this version. Pin ng-recaptcha to v11.x.x to retain support for a previous Angular version

11.0.0 (2022-11-30)

Features

  • component: deprecate error output in favor of errored (6b002bb)
  • package: add Angular 15 support (6c62634), closes #275

10.0.0 (2022-06-25)

Features

  • package: add Angular 14 support (eac6858)

9.0.0 (2021-11-16)

Features

  • package: upgrade to Angular 13 (af08641), closes #245

8.0.1 (2021-07-22)

Bug Fixes

  • component: reset form-bound captcha value after component destruction (0e550c4), closes #201

8.0.0 (2021-05-14)

Features

  • package: add Angular 12 support (a212a21)

7.0.2 (2021-07-22)

Bug Fixes

  • component: reset form-bound captcha value after component destruction (9e5c5e7), closes #201

7.0.1 (2021-01-07)

Bug Fixes

  • component: fix component usages for Typescript strict mode (a687d13), closes #211

7.0.0 (2020-12-22)

Bug Fixes

  • package: make @types/grecaptcha a non-optional dependency (bc5ad51), closes #205

Features

  • component: Add Angular 11 support (918fe90)
  • component: remove deprecated forRoot method (514beaf)
  • package: update "@types/grecaptcha" optional dependency version to ^3 (e1ee7b9)

BREAKING CHANGES

  • component: Support for previous versions of Angular has been dropped. Starting from v7 only one version of Angular will be supported.
  • component: The RecaptchaModule.forRoot() method has been obsolete since v4.1.0 (since it has no longer been required). It is now removed. To migrate your code, simply use RecaptchaModule where you previously used RecaptchaModule.forRoot()

6.1.0 (2020-12-01)

Bug Fixes

  • component: handle top-level execute errors for reCAPTCHA v3 (c7d02ce), closes #194
  • component: mark forRoot() method as deprecated (dea31e5)

Features

  • component: add the ability to handle reCAPTCHA errors (80c9e6e), closes #199

6.0.2 (2020-09-14)

Bug Fixes

  • component: fix custom languages for reCAPTCHA v3 (a2b145d), closes #174
  • component: improve reCAPTCHA v2 and v3 interoperability (79fc85b), closes #152

6.0.1 (2020-09-12)

Bug Fixes

  • component: catch and propagate grecaptcha errors, closes #175 (075edd0)

6.0.0 (2020-09-10)

Features

  • component: make Angular 10.0.0 a supported peer dependency (3d7756b), closes #177
  • component: make Angular 9.0.0 a supported peer dependency (98edce6), closes #168

5.0.0 (2019-08-09)

Features

  • component: make Angular 8.0.0 a supported peer dependency (f003ff2)
  • package: implement Angular Package format (71340c4)

BREAKING CHANGES

  • package: * ng-recaptcha/forms entry point has been removed. RecaptchaFormsModule and RecaptchaValueAccessorDirective should now be imported directly from ng-recaptcha
  • tslib is now a package dependency to ensure minimum possible bundle size. If your project doesn't yet have a dependency on tslib, run npm install -D tslib@^1.9.0 (or yarn add -D tslib@^1.9.0 if you use yarn)

4.3.0 (2019-06-04)

Bug Fixes

  • component-v3: fix a potential metadata error in v3 service (ed885b5)

4.3.0-beta.1 (2019-02-08)

Features

  • component: add support for reCAPTCHA v3 (4a083c6), closes #129

4.2.1 (2018-10-24)

Bug Fixes

  • package: fix publishing empty package (e4685fe)

4.2.0 (2018-10-24)

Features

  • component: add the ability to provide nonce to the script tag (8f55b19), closes #100
  • component: allow to specify a base url for loading recaptcha (df505fd), closes #101

4.1.1 (2018-10-24)

Bug Fixes

  • component: delay invisible recaptcha execution until it's rendered (99292b7), closes #127

4.1.0 (2018-10-24)

Bug Fixes

  • component: fix a potential error during recaptcha rendering (1c395b5)

Features

  • module: skip forRoot() when importing RecaptchaModule (7fb97fb), closes #113 #116
  • package: update peer dependencies to include Angular 7 (929ef7a)

4.0.0 (2018-09-29)

4.0.0-beta.1 (2018-05-17)

Features

  • component: adjust dependencies for Angular 6 support (736c7ae)

BREAKING CHANGES

  • component: The peer dependency for @angular/core has been bumped to ^6.0.0

3.0.5 (2018-04-27)

Bug Fixes

  • rxjs: change import of of operator (3e0bda6), closes #95

3.0.3 (2017-12-26)

Bug Fixes

  • component: use ElementRef to access component's native element (d3a8409), closes #48 #68

3.0.2 (2017-10-18)

Bug Fixes

3.0.1 (2017-09-29)

Bug Fixes

  • component: Replace OpaqueToken with InjectionToken (2b7db9b)

3.0.0 (2017-08-30)

Bug Fixes

  • component: fix server-side rendering (7a5bc6c), closes #34

BREAKING CHANGES

  • component: Angular v2.x.x is no longer supported due to dependency on Platform capabilities that were added in v4.0.0-rc.1

2.2.0 (2017-08-18)

Bug Fixes

  • component: ensure that component is destroyed safely (1e51d56), closes #46

Features

  • component: add the ability to specify component props globally (8a7b22d), closes #45

2.1.1 (2017-05-02)

Bug Fixes

  • component: unblock protractor tests after <re-captcha> destruction (a5f2fe9)

2.1.0 (2017-05-01)

Features

  • component: add support for badge property (5a16430), closes #30

Bug Fixes

  • demo: re-add a missing systemjs config file (b51694a)

2.0.2 (2017-03-26)

Features

  • package: update peer dependencies to include Angular v4 (b2f04e8)

2.0.1 (2017-03-17)

Bug Fixes

  • module: Adding the value accessor directive to the forms barrel, which was missing. (ad73e2e)

Features

  • misc: Annotating a static field with @nocollapse to avoid issues with closure compiler in advanced mode. (55e5932)

2.0.0 (2017-03-14)

Features

  • component: change component and directive selectors (58a01b4)
  • module: change the way recaptcha modules work (6e13389)

BREAKING CHANGES

  • component: component selector changed from recaptcha to re-captcha
  • module: module handling has changed. Users of RecaptchaNoFormsModule should instead use import { RecaptchaModule } from 'ng-recaptcha'. Users of v1 RecaptchaModule should also import { RecaptchaFormsModule } from 'ng-recaptcha/forms'. SystemJS users must also re-setup module "main" file to index.js

1.7.0 (2017-03-13)

Bug Fixes

  • component: handle id input parameter correctly (b578fe5)

Features

  • component: add exportAs annotation (3e2e217)
  • component: add support for invisible reCAPTCHA (c19489d), closes #18

1.6.1 (2017-03-10)

Enhancements

  • package: expand wildcard exports to better support Google Closure Compiler (8dd1a59)

1.6.0 (2017-02-17)

Features

  • package management: add [@types](https://github.com/types)/grecaptcha as optional dependency (85fbfba)

1.5.4 (2017-02-02)

Bug Fixes

  • component: correctly reset captcha during ngOnDestroy (b31d57f), closes #12

1.5.3 (2017-02-01)

Bug Fixes

  • component: emit resolved(null) event when recaptcha expires (491d99a), closes #11

1.5.2 (2017-01-31)

Bug Fixes

  • component: reset the captcha when the component is destroyed (e1441c8), closes #10

1.5.1 (2017-01-27)

1.5.0 (2017-01-24)

Bug Fixes

  • component: correctly emit resolved event (25d4246)

1.4.0 (2016-10-28)

Added AoT compilation support