> For the complete documentation index, see [llms.txt](https://guardient.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guardient.gitbook.io/docs/getting-started/integration/guardient-js-sdk.md).

# Guardient JS SDK

Our JavaScript SDK is versatile and can be seamlessly integrated with virtually any Node.js-supported backend framework. This wide compatibility ensures that developers can efficiently use the SDK with popular frameworks and libraries such as Next.js, SvelteKit, Express.js, and Qwik. The list of compatible environments is extensive, ensuring that whether your project is web-based, server-side, or hybrid, our SDK provides a reliable and efficient solution.

{% stepper %}
{% step %}

### Install guardient sdk as an package

{% tabs %}
{% tab title="npm" %}

```bash
npm install guardient-sdk
```

{% endtab %}

{% tab title="bun" %}

```bash
bun add guardient-sdk
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn add guardient-sdk
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm add guardient-sdk
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Add guardient before or after signing up an user

Make sure to verify with Guardient before allowing user sign-ups. If that's not possible *(Using a sign-up framework like Clerk or Supabase),* sign them up first, then verify, and then block any accounts that don't meet your expectations.

> Replace `<API_KEY>` with your real API key. Check our [introduction page](/docs/getting-started/introduction.md) for help on getting it.

```typescript
import { verifyWithGuardient } from "guardient-sdk"

// This is an example of how you can use the Guardient SDK to verify a user during sign-up.
export async function verifySignUp(email: string, ip: string, phone: string) {
  const response = await verifyWithGuardient(
    {
      email,
      ip,
      phone,
    },
    "<API_KEY>"
  )

  // Something went wrong, we are throwing an error for example
  if (!response.success) {
    return {
      allow: false,
      error: response.error,
    }
  }

  // If the trust score is below 70, we don't allow the user to proceed.
  if (response.data!.trustScore < 70) {
    return {
      allow: false,
      error: "Trust score is too low, you cannot proceed.",
    }
  }
  // Let's block the user if they have vpn enabled no matter the trust score.
  else if (response.data!.signals.includes("vpn_ips")) {
    return {
      allow: false,
      error: "VPN detected, you cannot proceed.",
    }
  }

  // Everything looks good, we can allow the user to proceed.
  return {
    allow: true,
  }
}
```

As you can see, Guardian lets you decide if you want to block the user or not; it is very flexible. You can write your own logic to decide whether to block the user, unlike our competitors.

We would like to note that this is an example of how you can use Guardian in your web service. You are still required to code the part to take the action; we can't do that for you since every framework differs from each other. We are planning to provide examples for the most popular frameworks in the future,
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://guardient.gitbook.io/docs/getting-started/integration/guardient-js-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
