@flotiq/nextjs-addon
v0.1.4
Published
Support for Next.JS framework in flotiq-api-sdk
Readme
@flotiq/nextjs-addon
Home for Next.js + Flotiq integrating code, including @flotiq/flotiq-api-sdk middleware, that enhances requests to Flotiq api with Next.js functionality:
- All Flotiq requests are tagged with next fetch tags:
- Each request gets
flotiq-contenttag - Requests for content objects get
flotiq-content-<ctd_name>tags - in production, requests will be cached (by default for 1 day)
- requests in
draftModeaccess latest Flotiq data (including drafts) and have cache disabled - requests in
NODE_ENV === "development"have no cache
- Each request gets
Installation
npm install @flotiq/nextjs-addonUsage
import { Flotiq } from "@flotiq/flotiq-api-sdk";
import { createNextMiddleware } from "@flotiq/nextjs-addon";
const api = new Flotiq({
middleware: [createNextMiddleware()],
});You can pass the following options in the createNextMiddleware function:
const api = new Flotiq({
middleware: [createNextMiddleware({
tagNamePrefix: "flotiq-content", // prefix for all next cache tags.
revalidateTime: 24 * 60 * 60, // how long data is cached after being fetched from Flotiq, default is equivalent to 1 day
})],
});