1.0.2 • Published 2 years ago

@side/next-bootstrap v1.0.2

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

Release

Prerequisites

This library comes baked-in to our template-nextjs repository. In order to create a new NextJS app, go to the template repository and click Use this template. This template ships with the relevant client and server side scripts to work with.

If you are integrating this package within an existing project, you need to create a script depending on your requirements. Scripts can be written in either JavaScript or TypeScript. Client-side script injection is placed within bootstrap.client.config[js|ts], server-side scripts go in bootstrap.server.config.[js|ts]. You must configure one or both of these files or you will receive an error.

Installation

Install this package by running the following command:

yarn add @side/next-bootstrap

Usage

Once installed and added to your project, implement the library within the next.config.js in your project.

The interface for the lib is through importing the withBootstrapConfig supports both ways of constructing the next config as detailed in the next documentation. export in your next.config.js and passing either your next config as an object or a function into withBootstrapConfig.

Config as an Object

import { withBootstrapConfig } from '@side/next-bootstrap`;

/** @type {import('next').NextConfig} */
const nextConfig = {
  basePath: '/foo',
  async redirects() {
     ...
  }
  ...
};

/** @returns {import('next').NextConfig}
module.exports = withBootstrapConfig(nextConfig);

Config as a Function

import { withBootstrapConfig } from '@side/next-bootstrap`;

/** @type {import('@side/next-bootstrap').NextConfigFunction} */
const nextConfigFunction = (phase, { defaultsObject }) => {
  /** @type {import('next').NextConfig} */
  return {
    basePath: '/foo',
    async redirects() {
       ...
    }
    ...
  };
};

/** @returns {import('@side/next-bootstrap').NextConfigFunction}
module.exports = withBootstrapConfig(nextConfigFunction);