---
title: JS Constants
---

# JS Constants

<div class="documentation__toc"></div>

## Including Constants

You can include the JS constants by placing `constants()` in your `<head>`.
 
```twig
{{ constants() }}
```

> Constants are included by default when creating a theme.{.tip}

## Available Constants

### APPLICATION_URL

The full base URL of the application.

```js
window.location = APPLICATION_URL;
```

### APPLICATION_REFERENCE

The reference of the application defined by environment data.

```js
let log = new XMLHttpRequest();

log.open('GET', REQUEST_ROOT_PATH + '/app/' + APPLICATION_REFERENCE + '/process.log', true);
log.setRequestHeader('Content-Type', 'application/json');

log.send();
```

### APPLICATION_DOMAIN

The domain of the application defined by environment data.

```js
window.location = 'https://' + APPLICATION_DOMAIN;
```

#### CSRF_TOKEN

The CSRF token value. This is helpful when sending requests to your application with JS.

```js
let request = new XMLHttpRequest();

request.open('POST', REQUEST_ROOT_PATH + '/example/toggle', true);
request.setRequestHeader('Content-Type', 'application/json');

request.send(JSON.stringify({
    _token: CSRF_TOKEN
}));
```

### APP_DEBUG

A boolean flag indicating whether debugging is enabled or not.

```js
if (APP_DEBUG) {
    console.log(data);
}
```

### APP_URL

The application URL as defined by configuration.

```js
window.location = APP_URL;
```

### REQUEST_ROOT

The entire request root.

### REQUEST_ROOT_PATH

```js
let log = new XMLHttpRequest();

log.open('GET', REQUEST_ROOT_PATH + '/app/' + APPLICATION_REFERENCE + '/process.log', true);
log.setRequestHeader('Content-Type', 'application/json');

log.send();
```

The request root path.

### TIMEZONE

The configured application timezone.

```js
console.log(TIMEZONE); // America/Chicago
```

### LOCALE

The configured application locale.

```js
console.log(LOCALE); // en
```
