Skip to content

altcha-org/altcha-starter-angular

Repository files navigation

ALTCHA Widget with Angular

This is an example Angular project using the ALTCHA widget.

Overview

ALTCHA is a free, open-source, self-hosted solution designed to protect websites, APIs, and online services from spam and unwanted content. It leverages a proof-of-work mechanism and is fully GDPR compliant, as it does not use cookies, fingerprinting, or tracking of any kind.

Get Started

To quickly get your project up and running with the ALTCHA widget, follow these steps:

  1. Clone this repository and navigate to the project directory:
git clone https://github.com/altcha-org/altcha-starter-angular.git
cd altcha-starter-angular
  1. Install the project dependencies:
npm install
  1. Start the development server:
npm start

Creating a New Project

If you prefer to create a new project from scratch, here are the steps:

  1. Create a new Angular project:
ng new my-angular-app
  1. Navigate to your project directory:
cd my-angular-app
  1. Install the ALTCHA widget package:
npm install altcha --save
  1. Import the altcha package in your project:
// src/main.ts
import 'altcha';
  1. Use the <altcha-widget> element in your component:
<!-- src/app/example/example.component.html -->
<div>
  <h1>My Angular App with ALTCHA</h1>
  <altcha-widget challengeurl="https://your-challenge-url.com"></altcha-widget>
</div>
  1. If you don't already have an example component, create one:
ng generate component example
  1. Update Component schemas to support custom Web Components:
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})

Reactive Forms

The example component app-altcha can be used in reactive forms as a required form control. The value of the form control will be the ALTCHA payload. This setup allows you to easily integrate the ALTCHA component into your forms, ensuring that it participates in form validation and submission just like any other form control.

Additional Configuration

Ensure your challengeurl points to the endpoint where ALTCHA's proof-of-work challenge is processed. Customize the component attributes as needed based on your specific use case.

Conclusion

With these steps, you should have a Lit project running with the ALTCHA widget integrated. This setup helps protect your application from spam and unwanted content efficiently and compliantly. For more details, visit the ALTCHA documentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published