1.0.0 • Published 3 years ago

@salvagr/react-instagram-data-server v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

React Instagram Data (Server-side Rendering)

Easy way to get a beautiful media grid from any business instagram account. This version is adapted to be able to render the component on the server (New next.js 13, React server component, etc..).

IMPORTANT! If you wanna use this package, you need to have a App in developers.facebook.com with a instagram graph api connected.

Installation

npm install @salvagr/react-instagram-data-server
# OR
yarn add @salvagr/react-instagram-data-server

I use the env file to setup the functionality. Please follow the next step depending on your project.

NEXT.JS

# .env file
NEXT_PUBLIC_IG_ACCESS_TOKEN=...
NEXT_PUBLIC_IG_BUSINESS_ID=...

REACT APP

# .env file
REACT_APP_IG_ACCESS_TOKEN=...
REACT_APP_IG_BUSINESS_ID=...

Example usage

import { Instagram } from '@salvagr/react-instagram-data-server';

export default function App() {
  return (
    <div>
      <Instagram
        username="instagram"
      />
    </div>
  );
};

Change the style

You can change the style and add your own. Each component has a name assigned (next table), you can use the React style to change the css of the component.

KeyDefault
profileContainerbackgroundColor: #F5F5F5display: 'flex'alignItems: 'center'maxWidth: '300px'justifyContent: 'space-evenly'padding: '10px'borderRadius: '20px'fontFamily: '#Poppins'`
profileImageborderRadius: '100vh'maxWidth: '80px'
profileDataContainerh2 : {margin: '0.5rem 0',fontSize: '21px'}
profileFollowsContainerp : {margin: '0.4rem 0',fontSize: '14px'}
mediaContainerbackgroundColor: #F5F5F5display: 'flex'gap: '1rem'justifyContent: 'center'alignItems: 'flex-start'marginItems: '1rem'padding: '1rem'borderRadius: '20px'flexWrap: 'wrap'
mediaBoxbackgroundColor: #fffwidth: '300px'borderRadius: '20px'display: 'flex'flexDirection: 'column'flexWrap: 'wrap'position: 'relative'zIndex: '1'a: {textDecoration: 'none',color: '#121212'}image: {maxWidth: '100%',borderRadius: '20px',display: 'block'}
overlaybackgroundColor: rgba(0,0,0,0.0)transform: 'scale(0)'transition: 'background .25s cubic-bezier(0.4, 0.0, 0.2, 1), visibility 0s linear .25s'position: 'absolute'width: '100%'height: '100%'top: 0borderRadius: '20px'fontFamily: 'Poppins'content: {color: 'white',position: 'absolute',top: '50%',left: '50%',transform: 'translate(-50%, -50%),infoRows: {display: 'flex',alignItems: 'center',gap: '0.3rem'}}
import { Instagram } from '@salvagr/react-instagram-data-server';

export default function App() {
  return (
    <div>
      <Instagram
        username="instagram"
        style={{
          profileContainer: {
            backgroundColor: '#FFAAAA'
          }
        }}
      />
    </div>
  );
};

Limit

You can limit the post results.

<Instagram
  limit={8}
  username="instagram"
/>

Client Component

Client-side rendering is still available from the react-instagram-data package.