> For the complete documentation index, see [llms.txt](https://docs.zep.us/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zep.us/zep-script/zep-script-api/scriptapp/storage.md).

# Storage

### How to Store Data in App Storage

> **Recommended**

{% hint style="info" %}
App.setStorage(string);
{% endhint %}

The App.setStorage function is a data storage function complementing existing app data storage methods.

> **Not recommended**

{% hint style="danger" %}
App.storage = string;\
App.save();
{% endhint %}

If the app is running on several maps in the same Space, the above method may cause issues such as data being overwritten.

### How to Read the App Storage Value

{% hint style="info" %}
App.getStorage(function(){})
{% endhint %}

The App.getStorage function helps synchronize the app data so that it can have the same data by checking if the same app is running on another map within the same Space.

{% hint style="warning" %}
As the App.getStorage function is an asynchronous function, synchronization cannot be guaranteed if you add a code that uses App.storage on the very next line of this function.
{% endhint %}

### App Storage Example

Install the example code below as a sidebar app and press Q on another map in the same Space to see if the "count" value is synchronized.

```javascript

App.onStart.Add(function(){
	if(App.storage == null){
		App.setStorage(JSON.stringify({count: 0}))
	}
})
// // Activates function when q is pressed
App.addOnKeyDown(81,function(player){
	// Updates App.storage and executes a callback function
	App.getStorage(function () {
		let appStorage = JSON.parse(App.storage);
		appStorage.count += 1;
		App.sayToAll(`count: ${appStorage.count}`)
		// Uses App.setStorage to save any changes
		App.setStorage(JSON.stringify(appStorage));
	});
	// Synchronization not guaranteed if you add a code that uses App.storage on the very next line of the App.getStorage function.
	App.sayToAll(App.storage);
})
```


---

# 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.zep.us/zep-script/zep-script-api/scriptapp/storage.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.
