tomashco

payload instagram plugin

by tomashco
Third-party services
v3
^3.0.0
MIT

Overview

Summary generated from the README

Adds an instagram-posts collection and a custom admin view that previews posts from a connected Instagram account. Editors pick posts to import, which can then be queried or referenced through relationship fields. The access token is stored in the database and refreshes automatically. Requires an Instagram Business or Creator account, a Meta Developer App and HTTPS for OAuth redirects.

Features

  • Custom Instagram Posts admin view to preview connected posts and add them to the collection
  • instagram-posts collection storing image, video and carousel posts with captions and children
  • OAuth authorize, unauthorize and data deletion endpoints for the Meta app
  • Access token stored in the database and refreshed automatically every 10 days
  • Usable through local API queries or relationship fields in blocks

Use cases

  • Show selected Instagram posts inside blog pages built on Payload
  • Let editors curate which Instagram posts appear on a website via a relationship block

From the author

Instagram plugin for Payload CMS

Installation

npm i payload-instagram-plugin

27

Stars

3

Forks

3

Open Issues

9 months ago

Last Updated

40

Weekly Downloads

v0.2.2

npm Version

238.3 KB

Unpacked Size

0

Dependencies

GitHub stars

27+4 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202627
Dec 4, 202627
Dec 3, 202627
Dec 2, 202627
Dec 1, 202627
Nov 30, 202627
Nov 29, 202627
Nov 28, 202627
Nov 27, 202627
Nov 26, 202627
Nov 25, 202627
Nov 24, 202627
Nov 23, 202627
Nov 22, 202627
Nov 21, 202627
Nov 20, 202627
Nov 19, 202627
Nov 18, 202627
Nov 17, 202627
Nov 16, 202627
Nov 15, 202627
Nov 14, 202627
Nov 13, 202627
Nov 12, 202627
Nov 11, 202627
Nov 10, 202627
Nov 9, 202627
Nov 8, 202627
Nov 7, 202627
Nov 6, 202627
Nov 5, 202627
Nov 4, 202626
Nov 3, 202625
Nov 2, 202625
Nov 1, 202625
Oct 31, 202625
Oct 30, 202625
Oct 29, 202625
Oct 28, 202625
Oct 27, 202625
Oct 26, 202625
Oct 25, 202625
Oct 24, 202625
Oct 23, 202625
Oct 22, 202625
Oct 21, 202625
Oct 20, 202625
Oct 19, 202625
Oct 18, 202625
Oct 17, 202625
Oct 16, 202625
Oct 15, 202625
Oct 14, 202625
Oct 13, 202625
Oct 12, 202625
Oct 11, 202625
Oct 10, 202625
Oct 9, 202625
Oct 8, 202625
Oct 7, 202625
Oct 6, 202625
Oct 5, 202625
Oct 4, 202625
Oct 3, 202625
Oct 2, 202625
Oct 1, 202625
Sep 30, 202625
Sep 29, 202625
Sep 28, 202625
Sep 27, 202625
Sep 26, 202625
Sep 25, 202625
Sep 24, 202625
Sep 23, 202625
Sep 22, 202625
Sep 21, 202625
Sep 20, 202625
Sep 19, 202625
Sep 18, 202624
Sep 17, 202624
Sep 16, 202624
Sep 15, 202624
Sep 14, 202624
Sep 13, 202623
Sep 12, 202623
Sep 11, 202623
Sep 10, 202623
Sep 9, 202623
Sep 8, 202623
Sep 7, 202623
Sep 6, 202623
npm weekly downloads

4−4 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20264
Dec 4, 20264
Dec 3, 20263
Dec 2, 20263
Dec 1, 202621
Nov 30, 202621
Nov 29, 202620
Nov 28, 202620
Nov 27, 202620
Nov 26, 202622
Nov 25, 202622
Nov 24, 20263
Nov 23, 20263
Nov 22, 20266
Nov 21, 20266
Nov 20, 20266
Nov 19, 20265
Nov 18, 202622
Nov 17, 202623
Nov 16, 202625
Nov 15, 202625
Nov 14, 202625
Nov 13, 202627
Nov 12, 202638
Nov 11, 202621
Nov 10, 202620
Nov 9, 202619
Nov 8, 202617
Nov 7, 202618
Nov 6, 202615
Nov 5, 20263
Nov 4, 20263
Nov 3, 20264
Nov 2, 20266
Nov 1, 20265
Oct 31, 20264
Oct 30, 20264
Oct 29, 20264
Oct 28, 20264
Oct 27, 20264
Oct 26, 20261
Oct 25, 20263
Oct 24, 20264
Oct 23, 20264
Oct 22, 20267
Oct 21, 202625
Oct 20, 202624
Oct 19, 202625
Oct 18, 202623
Oct 17, 202623
Oct 16, 202623
Oct 15, 202631
Oct 14, 202639
Oct 13, 202644
Oct 12, 202647
Oct 11, 202648
Oct 10, 202647
Oct 9, 202647
Oct 8, 202636
Oct 7, 202610
Oct 6, 20265
Oct 5, 20261
Oct 4, 20260
Oct 3, 20264
Oct 2, 20265
Oct 1, 20266
Sep 30, 20266
Sep 29, 202624
Sep 28, 202624
Sep 27, 202625
Sep 26, 202624
Sep 25, 202625
Sep 24, 202624
Sep 23, 202624
Sep 22, 202624
Sep 21, 202624
Sep 20, 202624
Sep 19, 202621
Sep 18, 202621
Sep 17, 202623
Sep 16, 202625
Sep 15, 20267
Sep 14, 20269
Sep 13, 20269
Sep 12, 20269
Sep 11, 202611
Sep 10, 20269
Sep 9, 20268
Sep 8, 20268
Sep 7, 20269
Sep 6, 20268

Each point is npm's rolling 7-day download count.

Health Score

44/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/807004484-root.svg)](https://payloaddirectory.dev/plugins/807004484-root)
HTML
<a href="https://payloaddirectory.dev/plugins/807004484-root"><img src="https://payloaddirectory.dev/badge/807004484-root.svg" alt="Payload Directory"></a>
Updated Mar 3, 2026Created May 28, 2024Published Mar 3, 2026

README

Payload Instagram Plugin

This plugin allows you to use an Instagram connected feed as content to be shown inside a Payload CMS blog.

Important: Starting from 0.0.8, the access token is stored in the database and refreshes automatically. The token refreshes every 10 days and is valid for 60 days.

Requirements

  • Instagram Business or Creator account — a personal Instagram account will not work. See the Setup Guide for how to convert your account (free, reversible).
  • Meta Developer App with Instagram product configured.
  • HTTPS — Instagram requires HTTPS for OAuth redirects, even on localhost.

How to setup

Follow the Setup Guide for detailed step-by-step instructions covering:

  1. Converting your Instagram account to Business/Creator
  2. Creating and configuring a Meta Developer App
  3. Installing and authorizing the plugin

Quick summary:

Set your redirect URI in the Meta Developer App to:

https://yourBaseUrl/api/instagram/authorize

Replace yourBaseUrl with your app URL. If running locally, use --experimental-https to start your dev server with HTTPS.

Also set:

  • Revoke authorization URL: https://yourBaseUrl/api/instagram/unauthorize
  • Data deletion request URL: https://yourBaseUrl/api/instagram/delete

Add the plugin to your payload.config.ts:

import { instagramPlugin } from 'instagram-payload-plugin'

export default buildConfig({
  plugins: [
    instagramPlugin({ enabled: true })
  ],
})

How to use

In the admin view, a new collection called instagram-posts is added. Do not add items to this collection manually!

A custom view called Instagram Posts is added to the left panel, allowing you to preview all connected Instagram posts. From here you can click on any post to add it to the collection.

Item types

The items in the collection have this structure:

type PostType = {
  id: string
  media_url: string
  permalink: string
  media_type: 'IMAGE' | 'VIDEO' | 'CAROUSEL_ALBUM'
  caption: string
  children?: {
    id: string
    media_url: string
    permalink: string
    media_type: string
  }[]
}

Type CAROUSEL_ALBUM will have an additional array of children, each being the actual image of the carousel (i.e. more than one image in a post).

How to import items into the page

Method 1: instagram-posts is a regular Payload collection, so you can query it like any other:

import configPromise from '@payload-config'
import { getPayload } from 'payload'

const payload = await getPayload({ config: configPromise })

const { docs } = await payload.find({
  collection: 'instagram-posts',
  depth: 3,
})

Method 2: Create a relationship block:

const InstagramIntegration: Block = {
  slug: 'InstagramIntegration',
  interfaceName: 'InstagramIntegrationBlock',
  fields: [
    {
      name: 'instagramSrc',
      type: 'relationship',
      required: true,
      relationTo: 'instagram-posts',
    },
  ],
}

Then use the component data:

const InstagramIntegration = ({ instagramSrc }: { instagramSrc: PostType }) => {
  const { media_type, media_url, caption, children } = instagramSrc
  return (
    <section className="relative flex">
      <Container>
        {media_type === 'CAROUSEL_ALBUM' && (
          <Carousel>
            <CarouselContent>
              {children?.map(({ media_url }) => (
                <CarouselItem key={media_url}>
                  <div className="relative h-[400px] w-full">
                    <Image layout="fill" objectFit="contain" src={media_url || ''} alt="carousel image" />
                  </div>
                </CarouselItem>
              ))}
            </CarouselContent>
            <CarouselPrevious />
            <CarouselNext />
          </Carousel>
        )}
        {caption && (
          <div className="w-full p-6 dark:text-zinc-100">
            <p>{caption}</p>
          </div>
        )}
      </Container>
    </section>
  )
}

How to delete an item

To delete an item, simply delete the entry from the collection view.

Similar plugins