# Native Datastore

This can be useful for saving preferences, user settings, or small amounts of data that should persist across app sessions without requiring network requests. With Twinr’s Native Datastore, you can store integers, booleans, and strings, as well as retrieve them when needed.

## Store Int Data

Stores an integer value locally on the device under a specified key.

```javascript
twinr_set_int_local_data("userScore", 100);
```

In this example, the integer 100 is saved under the key "userScore".

## Store String Data

Stores a string value locally on the device under a specified key.

```javascript
twinr_set_string_local_data("userName", "JohnDoe");
```

In this case, the string "JohnDoe" is saved under the key "userName".

## Store Bool Data

Stores a boolean value (true/false) locally on the device under a specified key.

```javascript
twinr_set_bool_local_data("isLoggedIn", true);
```

Here, the boolean value true is stored under the key "isLoggedIn".

## Get Local Data

Retrieves a value stored locally on the device using the specified key.

```javascript
await twinr_get_local_data("userScore");
```

In this example, the value stored under "userScore" is retrieved. The function returns a promise that resolves to the stored value.


---

# 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://help.twinr.dev/js-bridge/native-datastore.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.
