Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miladsoft/mini-apps
https://github.com/miladsoft/mini-apps
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/miladsoft/mini-apps
- Owner: miladsoft
- License: mit
- Created: 2024-06-27T22:09:58.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-06-28T11:55:58.000Z (4 months ago)
- Last Synced: 2024-10-11T02:49:34.636Z (28 days ago)
- Language: TypeScript
- Size: 253 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelogithub.config.json
- License: LICENSE
Awesome Lists containing this project
README
## Installation
To install the `@miladsoft/mini-apps-sdk` library using npm, run the following command:
```sh
npm install @miladsoft/mini-apps-sdk
```## Usage
To use the library in your project, follow these steps:
1. **Import the Library:**
First, you need to import the necessary modules from the library. Use the following import statement in your JavaScript or TypeScript file:
```js
import { init } from '@miladsoft/mini-apps-sdk'
```2. **Initialize the SDK:**
Call the `init` function to initialize the SDK and get access to various features and components provided by the library:
```js
const {
ready,
mainButton,
close,
} = init()
```3. **Prepare the App:**
Use the `ready` method to signal that your app is ready. This is usually done after all initial setup is complete:
```js
ready()
```4. **Configure the Main Button:**
You can customize the main button's text and define its behavior when clicked. For example, to set the text to "CLOSE MINI APP" and close the app when clicked, you can do the following:
```js
mainButton.text = 'CLOSE MINI APP'
mainButton.onClick(() => close())
```Here is a complete example that puts all the steps together:
```js
import { init } from '@miladsoft/mini-apps-sdk'// Initialize the SDK
const {
ready,
mainButton,
close,
} = init()// Signal that the app is ready
ready()// Configure the main button
mainButton.text = 'CLOSE MINI APP'
mainButton.onClick(() => close())
```By following these steps, you can successfully integrate and use the `@miladsoft/mini-apps-sdk` library in your project.