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

# Get Started

{% hint style="info" %} <mark style="color:blue;">**This document is for old version of nonstress. check latest version of nonstress:**</mark> <https://nonstress.mintlify.app/>
{% endhint %}

## Add Script Tag

Add this tag to your website's html to use nonstress in the page.

```javascript
<script src="https://hamutan86.pythonanywhere.com/nonstress/nonstress.js" async defer></script><script src="https://hamutan86.pythonanywhere.com/nonstress/nonstress.js" async defer></script>
```

Now your page is prepared to being protected by nonstress!

## Get The Token

You need "token" to check request's validity on server side. the token will be created automatically when the user opened your page.

When the token is ready, `nonstressCompleted` Event will be dispatched.\
Seeing is believing, check this example code:

```javascript
document.addEventListener("nonstressCompleted", (e) => {
    console.log(e.detail.success); // true|false
    console.log(e.detail.token); // "0dc240c66802f7329a1cb9f85804c49f6bb34a..."
});
```

When `e.detail.success` was false, it means failed to verify the user.\
In that case, you can't get token. so you have to reload the page, or use [nonstress.generateToken()](#regenerate-the-token) .\
\
You can get the token directly even the Event is already dispatched:

```javascript
nonstress.getToken(); // "0dc240c66802f7329a1cb9f85804c49f6bb34a..."
```

It's pretty simple. in this case, it returns empty string when nonstress isn't completed or it's failed.

## Regenerate The Token

Oh, user typo the password, cancelled action, or nonstress failed? if token is once validated, it can't be reused, but you don't have to reload the page.

Here's magic:

```javascript
nonstress.generateToken()
```

It will regenerate the token, redispatch the Event and overwrite nonstress.getToken() .
