Using Little Eagle with JavaScript

Install

The Little Eagle NPM package @littleeagle/images-node is designed to be used on the server, such as with Node.js, Next.js, or Remix.

To install it, run:

npm add @littleeagle/images-node

Generating an image

Use the littleEagleImagesURL function to generate an image.

import { littleEagleImagesURL } from '@littleeagle/images-node';

const projectID = process.env.LITTLE_EAGLE_PROJECT_ID;
const projectSecret = process.env.LITTLE_EAGLE_PROJECT_SECRET;

// Create the image with the overlay template and two lines of text.
const imageURL = littleEagleImagesURL({ id: projectID, secret: projectSecret }, {
  template: 'overlay',
  width: 1200,
  height: 630,
  backgroundColor: '#000',
  text: [
    { text: 'First line of text', size: 24, color: '#00b4ff' },
    { text: 'Second line of text', size: 16, color: '#fff' },
  ]
});

littleEagleImagesURL({ id: string; secret: string }, options)

id
The unique ID of your project.
secret
The secret of your project, used for signing your URL.
options.template
One of overlay, overlay-left, message, or plain.
options.width
The width of your image in pixels.
options.height
The height of your image in pixels.
options.backgroundColor
The background color in hex RGB. For example: #4598ab
options.imageURL
The main hero image. Pass a full URL.
options.logoURL
Your logo image. Pass a full URL.
options.text
An array of up to 2 lines of text. Each line should have a text, size, and color.