> For the complete documentation index, see [llms.txt](https://docs.tokensfarm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokensfarm.com/for-developers/integrate-tokensfarm/how-to-embed-tokensfarm.md).

# How to Embed TokensFarm

### How to Add <a href="#how-to-add" id="how-to-add"></a>

Include the following in your website's HTML code:

```html
<script src="https://tf-embedded.pages.dev/dist/embedded/TFLoader.js" type="text/javascript"></script>
// Some code
```

once script will be loaded `window.TF` object will be exposed. before use you need init with a valid params

```javascript
  function initTokensFarm() {
	document.addEventListener('tf-farm-loaded', (event) => {
		// farm object to verify and determinate when farm is loaded
		console.log(event.detail.farm);
		// if you need to override any style color
		document.documentElement.style.setProperty('--tf-emb-overlay-color', '#000000');
	});
	TF.init({
		dynamicId: '....', // dynamic environment id for wallet connectivity 
		id: 'embedded', // id of html element where you want to inject 
		farmType: 'lp', // farm type (you can find in tokensfarm.com)
		nonce: 15, // farm nonce (you can find in tokensfarm.com)
		token: 'XCAD', // farm tokenSymbol (you can find in tokensfarm.com)
		darkMode: true // theme light/dark
	});
}

document.addEventListener("DOMContentLoaded", (event) => {
	if (TF?.init) {
		initTokensFarm();
	} else {
		document.addEventListener('tf-loaded', initTokensFarm);
	}
});
```

after farm object will be loaded you can open/close modal

```javascript
  TF.show();
  // this will emit event
  document.addEventListener('tf-farm-modal-opened', () => ...)
  TF.hide();
  // this will emit event
  document.addEventListener('tf-farm-modal-closed', () => ...)
```

\
\
\ <br>


---

# 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://docs.tokensfarm.com/for-developers/integrate-tokensfarm/how-to-embed-tokensfarm.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.
