# Frontend: React Example

This is a simple [Create React App](https://create-react-app.dev/docs/getting-started) project, but these examples can be easily ported to your preferred framework or build tool.

Github: <https://github.com/deso-protocol/deso-examples-react>

### How to run these examples locally

Run the following in your terminal

```
git clone https://github.com/deso-protocol/deso-examples-react.git
cd deso-examples-react
npm i
npm run start
```

### How to use this repository

If you want to port these examples to your own app, set up a project using the docs for your preferred tool (Create React App, Vite, Nextjs, Remix, Angular, Vue, etc).

If you're not sure, Create React App is a reasonable choice for getting a development environment up and running for quick prototyping/experimenting.

Next, install the [DeSo Protocol SDK](https://www.npmjs.com/package/deso-protocol) using your preferred package manager:

```
# npm
npm i deso-protocol

# yarn
yarn add deso-protocol
```

Finally, use the examples found in this repo to help you build social features for your application.

There are lots of comments throughout the code, but if anything is unclear, please open an issue!

### Examples

* [Configuration](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/root.jsx#L7)
* [Login](https://github.com/deso-protocol/deso-examples-react/blob/main/src/components/nav.jsx#L27)
* [Logout](https://github.com/deso-protocol/deso-examples-react/blob/main/src/components/nav.jsx#L31)
* State Sync
  1. [Create a react context](https://github.com/deso-protocol/deso-examples-react/blob/main/src/contexts.js#L7)
  2. [Set up useState hook](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/root.jsx#L18)
  3. [Set up useEffect hook](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/root.jsx#L24)
  4. [Subscribe to identity](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/root.jsx#L40)
  5. [Instantiate a context provider](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/root.jsx#L117)
  6. [Use state from identity anywhere](https://github.com/deso-protocol/deso-examples-react/blob/main/src/components/nav.jsx#L8)
  7. [React to changes in your code](https://github.com/deso-protocol/deso-examples-react/blob/main/src/components/nav.jsx#L16)
* [Check permissions](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/sign-and-submit-tx.jsx#L8)
* [Request permissions](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/sign-and-submit-tx.jsx#L50)
* [Create, sign, submit a transaction](https://github.com/deso-protocol/deso-examples-react/blob/main/src/routes/sign-and-submit-tx.jsx#L61)


---

# 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://docs.deso.org/deso-frontend/exchange-listing-api-1.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.
