bc-frontend-library
v0.5.30
Published
BC Frontend library
Downloads
25
Readme
Binary Cloud Frontend NPM library
Overview
The Binary Cloud Frontend library allows you to seamlessly interact with a Strapi server to fetch pages and their respective data. This library is designed to simplify the process of retrieving and displaying content managed by Strapi in your frontend application.
Installation
To use the Binary Cloud Frontend library, you need to install it via npm. Run the following command in your project directory:
npm install bc-frontend-library
After installing the library, you can start using it to fetch pages and their data. The primary function you'll interact with is getPage. Additionally, the PAGES constant provides a list of all existing pages on the server.
Import the Library
import { getPage } from 'bc-frontend-library';
Add variables in env file
NEXT_PUBLIC_STRAPI_API_URL=https://binarycloudnz-backend.binarycloud.nz
NEXT_IMAGE_DOMAIN=binarycloudnz-backend.binarycloud.nz
Add configuration in next config
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: process.env.NEXT_IMAGE_DOMAIN,
},
],
},
};
Fetch a Page
Use the getPage function to retrieve a specific page and its data. You'll need to pass the name of the page as a prop