npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eitaa-miniapp

v1.0.11

Published

JavaScript library for Eitaa MiniApp integration, compatible with React, Vue, Angular, and plain JS.

Downloads

93

Readme

Eitaa MiniApp Integration Library

NPM Version

A JavaScript/TypeScript library for integrating Eitaa MiniApp features into modern JavaScript projects, compatible with React, Vue, Angular, and vanilla JavaScript.

📖 Overview

The eitaa-miniapp library simplifies the process of integrating Eitaa MiniApp functionalities into your web applications. It provides a comprehensive API wrapper, enabling seamless access to essential features such as interacting with the Eitaa WebApp, handling buttons, and more.

🚀 Features

  • Easy Initialization: Access the Eitaa MiniApp API with a single import.
  • Compatibility: Works with React, Vue, Angular, and plain JavaScript.
  • TypeScript Support: Includes complete type definitions for a smooth TypeScript experience.
  • Comprehensive API: Access to WebApp and WebView methods for versatile MiniApp interactions.

📦 Installation

Install the package via NPM:

npm install eitaa-miniapp

📚 Usage

Basic Setup

Import the library and start using EitaaMiniApp right away:

import { EitaaMiniApp } from "eitaa-miniapp";

// Example: Accessing the user's init data
console.log(EitaaMiniApp.WebApp.initData);

Example in a React Component

import React from "react";
import { EitaaMiniApp } from "eitaa-miniapp";

const App = () => {
  const userData = EitaaMiniApp.WebApp.initData;

  const handleMainButtonClick = () => {
    EitaaMiniApp.WebApp.MainButton.setParams({ text: "Clicked!" });
  };

  return (
    <div>
      <h1>User Data: {userData}</h1>
      <button onClick={handleMainButtonClick}>Click Me</button>
    </div>
  );
};

export default App;

Example in a Vue Component

<template>
  <div>
    <h1>User Data: {{ userData }}</h1>
    <button @click="handleButtonClick">Click Me</button>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import { EitaaMiniApp } from "eitaa-miniapp";

export default defineComponent({
  name: "EitaaComponent",
  setup() {
    const userData = ref(EitaaMiniApp.WebApp.initData);

    const handleButtonClick = () => {
      EitaaMiniApp.WebApp.MainButton.setParams({ text: "Clicked!" });
    };

    return { userData, handleButtonClick };
  }
});
</script>

Plain JavaScript Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Eitaa MiniApp Example</title>
</head>
<body>
  <h1 id="userData">User Data:</h1>
  <button id="actionButton">Click Me</button>

  <script type="module">
    import { EitaaMiniApp } from "./node_modules/eitaa-miniapp/dist/index.mjs";

    document.getElementById("userData").innerText = EitaaMiniApp.WebApp.initData;

    document.getElementById("actionButton").onclick = () => {
      EitaaMiniApp.WebApp.MainButton.setParams({ text: "Clicked!" });
    };
  </script>
</body>
</html>

🛠️ API Reference

EitaaMiniApp.WebApp

  • initData: Raw initialization data transferred to the MiniApp.
  • initDataUnsafe: Parsed initialization data. Includes user information such as user.id, user.username, etc.
  • MainButton: Controls the primary button at the bottom of the MiniApp.
    • enable(): Enables the button.
    • disable(): Disables the button.
    • show(): Shows the button.
    • setParams(params): Sets button parameters such as text, color, text_color.
  • BackButton: Controls the back button.
    • show(): Displays the back button.
    • hide(): Hides the back button.
  • showPopup(params): Displays a popup with specified title, message, and buttons.

🌍 Compatibility

  • React: ^16.8.0 and above
  • Vue: ^2.6.0 and above
  • Angular: ^9.0.0 and above
  • JavaScript: Compatible with both modern (ES6+) and legacy (ES5) JavaScript environments

🤝 Contributing

We welcome contributions! Feel free to submit issues, pull requests, or feature requests. For major changes, please discuss them in an issue first.