# Installation

## Installation

```
npm i stratox
```

*Or just download the zip and import Stratox.js file*

### Import Stratox

Start by importing "Stratox.js".

```js
import { Stratox } from './node_modules/stratox/src/Stratox.js';
```

### Config

None of the configs bellow is required for Stratox to work, but they will enable and extends some functionality. Just make sure that the config is executed before any Stratox class instances is called.

```js
Stratox.setConfigs({
    directory: "/absolute/path/to/views/", // Used for autoload
    cache: false, // Automatically clear cache if is false on dynamic import
    handlers: {
    	fields: StratoxTemplate, // Optional: will add form builder (se bellow)
    	helper: function() {
    	    // Pass on helper classes, functions and objects to your views
    	    return {
    		helper1: "Mixed data...",
                helper2: "Could be classes You want to",
                helper3: "Pass on to you components",
    	    };
    	}
    }
});
```

**directory:** Directory path for auto loaded asynchronously or imported templates. Either specify an absolute directory path or if opting for a relative path, **but** keep in mind it starts from the Stratox.js file location meaning if you bundle your files the relative location **will change** to where the bundle file is located at.

**cache:** Automatically clear cache if is false on dynamic import.

**handlers.fields:** Create a custom class handler for creating or modifying form field items, including default fields. The form field handler must extend the "StratoxBuilder" class, which is located in "node\_modules/stratox/src/StratoxBuilder.js". You can also create a new class (or copy the StratoxTemplate.js file) and extend your new class to StratoxTemplate if you want to add default fields or StratoxBuilder if you want to start fresh. Then just create your own form fields in your class. Read more under "Form builder" section.

**handler.helper:** Pass on helper classes, functions and objects to your views. If you are using a DOM traversal enginge then you could pass it on to the helper that in turn passes it on to your components, views and fields.


---

# Agent Instructions: 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:

```
GET https://stratox.wazabii.se/stratox.js/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
