Giter Club home page Giter Club logo

ng-hcaptcha's Introduction

Build status  GitHub license  GitHub issues  GitHub pull-requests

ng-hcaptcha - hCaptcha Component for Angular 7+

ng-hcaptcha provides an easy to use component for hCaptcha.

Table of Contents

Installation

Step 1 - Install the ng-hcaptcha dependency

# NPM
npm install --save ng-hcaptcha

# Yarn
yarn add ng-hcaptcha

You can use the tag 'next' to get the latest beta version.

Step 2 - Import the NgHcaptchaModule

import { NgHcaptchaModule } from 'ng-hcaptcha';

@NgModule({
    imports: [
        // Option #1
        // Set the sitekey globally for every hCaptcha component
        NgHcaptchaModule.forRoot({
            siteKey: 'YOUR_SITEKEY',
            languageCode: 'de' // optional, will default to browser language
        }),

        // Option #2
        // This option requires you to set the [siteKey] property for every hCaptcha component
        NgHcaptchaModule.forRoot()
    ]
})

Usage

Template:

<!-- Regular usage -->
<ng-hcaptcha (verify)="onVerify($event)"
              (expired)="onExpired($event)"
              (error)="onError($event)">
</ng-hcaptcha>

<!-- Usage in forms -->
<!-- The value of the form control will be the verification token -->
<form [formGroup]="formGroup" (submit)="onSubmit()">
    <ng-hcaptcha formControlName="captcha"></ng-hcaptcha>
</form>

<!-- Invisible captcha -->
<button ngHcaptchaInvisibleButton
        (verify)="onVerify($event)"
        (expired)="onExpired($event)"
        (error)="onError($event)">Click me</button>

TS:

onVerify(token: string) {
    // The verification process was successful.
    // You can verify the token on your server now.
}

onExpired(response: any) {
    // The verification expired.
}

onError(error: any) {
    // An error occured during the verification process.
}

Properties

The properties below exist for all captcha components.

siteKey Allows you to set the site key per captcha instance.

languageCode Allows you to force a specific language. See https://docs.hcaptcha.com/languages

Bugs? Ideas?

If you found a bug or something you don't like, feel free to open an issue. If you have any ideas for new features or improvements, feel free to contribute or open an issue 😉

Support me

If you would like to support me for free, just create your hCaptcha account using my referral link ☺️ https://hCaptcha.com/?r=4afcb2d42338

ng-hcaptcha's People

Contributors

lenicdev avatar simongh avatar

Watchers

Demon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.