All Projects → epaew → react-liff

epaew / react-liff

Licence: MIT license
A react context provider for LIFF (LINE Front-end Framework)

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-liff

react-simple-range
🔉 React slider component for inputting a numeric value within a range.
Stars: ✭ 20 (-9.09%)
Mutual labels:  react-component
react-carousel-minimal
React.js Responsive Minimal Carousel
Stars: ✭ 76 (+245.45%)
Mutual labels:  react-component
line-sdk-unity
Provides a modern way of implementing LINE APIs in Unity games, for iOS and Android.
Stars: ✭ 84 (+281.82%)
Mutual labels:  line
react-compare-slider
A slider component to compare any two React components in landscape or portrait orientation. It supports custom images, videos... and everything else.
Stars: ✭ 78 (+254.55%)
Mutual labels:  react-component
line-things-starter
The sample codes for LINE Things Developer Trial
Stars: ✭ 91 (+313.64%)
Mutual labels:  line
line-sdk-android
LINE SDK for Android lets you integrate LINE into your Android app to create a more engaging experience for your users.
Stars: ✭ 101 (+359.09%)
Mutual labels:  line
react-fusionui
☢️ Nuclear power-up for your UI.
Stars: ✭ 13 (-40.91%)
Mutual labels:  react-component
mighty-input
Text input for modern web
Stars: ✭ 20 (-9.09%)
Mutual labels:  react-component
react-example-paginated-list-infinite-scroll
Follow a React tutorial series with three parts to build a powerful component in React.
Stars: ✭ 43 (+95.45%)
Mutual labels:  react-component
react-fake-component
Chuck Norris faking components
Stars: ✭ 24 (+9.09%)
Mutual labels:  react-component
unosolo
Work-in-progress Rust application that converts C++ header-only libraries to single self-contained headers.
Stars: ✭ 26 (+18.18%)
Mutual labels:  line
react-windows-ui
Build Windows fluent UI apps using ReactJS. Provides a set of accessible, reusable, and composable React components that make it super easy to create websites and apps.
Stars: ✭ 383 (+1640.91%)
Mutual labels:  react-component
react-touch-ripple
Create ripple effect from Material Design with React
Stars: ✭ 27 (+22.73%)
Mutual labels:  react-component
win95-media-player
💿 Back from 1995, and running on your website
Stars: ✭ 56 (+154.55%)
Mutual labels:  react-component
markdown-navbar
Best markdown navigation bar for React.
Stars: ✭ 122 (+454.55%)
Mutual labels:  react-component
google streetview
A command line tool and module for Google Street View Image API
Stars: ✭ 77 (+250%)
Mutual labels:  line
colortest
Quickly show all your terminal colors
Stars: ✭ 66 (+200%)
Mutual labels:  line
react-form-base
Base React component for generic forms
Stars: ✭ 18 (-18.18%)
Mutual labels:  react-component
react-native-nested-listview
A UI component for React Native for representing nested arrays of N levels
Stars: ✭ 163 (+640.91%)
Mutual labels:  react-component
react-instagram-authless-feed
React component to provide a token-less Instagram feed.
Stars: ✭ 50 (+127.27%)
Mutual labels:  react-component

react-liff

npm version Build Status Maintainability

A react context provider for LIFF (LINE Front-end Framework)

Requirements

  • React v16.14 or later
    • React Native is not supported.
  • LIFF SDK version >=2.9.0

Getting started

When you use NPM version of LIFF SDK (Recommended)

  1. Create your React application development environment.

    • e.g. npx create-react-app app-name
  2. Add react-liff to your app dependencies.

    npm i --save @line/liff react-liff
    # or
    yarn add @line/liff react-liff
  3. Import react-liff to your app and use it!

    • An example of src/App.js

      import React, { useEffect, useState } from 'react';
      import { useLiff } from 'react-liff';
      
      import './App.css';
      
      const App = () => {
        const [displayName, setDisplayName] = useState('');
        const { error, liff, isLoggedIn, ready } = useLiff();
      
        useEffect(() => {
          if (!isLoggedIn) return;
      
          (async () => {
            const profile = await liff.getProfile();
            setDisplayName(profile.displayName);
          })();
        }, [liff, isLoggedIn]);
      
        const showDisplayName = () => {
          if (error) return <p>Something is wrong.</p>;
          if (!ready) return <p>Loading...</p>;
      
          if (!isLoggedIn) {
            return (
              <button className="App-button" onClick={liff.login}>
                Login
              </button>
            );
          }
          return (
            <>
              <p>Welcome to the react-liff demo app, {displayName}!</p>
              <button className="App-button" onClick={liff.logout}>
                Logout
              </button>
            </>
          );
        };
      
        return (
          <div className="App">
            <header className="App-header">{showDisplayName()}</header>
          </div>
        );
      };
      
      export default App;
    • An example of src/index.js

      import React from 'react';
      import ReactDOM from 'react-dom';
      import { LiffProvider } from 'react-liff';
      
      import './index.css';
      import App from './App';
      
      const liffId = process.env.REACT_APP_LINE_LIFF_ID;
      const stubEnabled = process.env.NODE_ENV !== 'production';
      
      ReactDOM.render(
        <React.StrictMode>
          <LiffProvider liffId={liffId} stubEnabled={stubEnabled}>
            <App />
          </LiffProvider>
        </React.StrictMode>,
        document.getElementById('root')
      );

When you use CDN version of LIFF SDK

  1. Create your React application development environment.
    • e.g. npx create-react-app app-name
  2. Add react-liff to your app dependencies.
    npm i --save react-liff
    # or
    yarn add react-liff
  3. Update index.html to load LIFF SDK
  4. Import react-liff to your app and use it!

API

LiffProvider props

  • liffId: string, required
    • The ID of your LIFF application.
    • When you using stubs, you can specify empty string.
  • stubEnabled: boolean | Object | undefined, optional
    • false or undefined: Provider uses LIFF SDK (for Production).
    • true: Provider uses stubs defined in library.
    • Object: Provider uses the stubs you specified here.
  • withLoginOnExternalBrowser: boolean, optional

LiffConsumer / useLiff return values

  • error: unknown (is LiffError | undefined in many cases)
    • Returns an error if liff.init() was failed.
  • isLoggedIn: boolean
    • Returns whether the user is logged in.
  • ready: boolean
    • Returns true after liff.init() or stub setup has successfully completed.
  • liff: Liff
    • Returns liff object.

CHANGELOG

CHANGELOG

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].