Plugin
The NextGlobeGen Plugin needs to be enabled in Next.js configuration file. It sets up the required import aliases for the package to work correctly. It also regenerates the localized routes, messages and the types for the package when changes are made in the source code.
createNextGlobeGenPluginโ
This function creates the wrapper function for your Next.js config object.
- next.config.ts
- next.config.mjs
- next.config.js
import type { NextConfig } from "next";
import createNextGlobeGenPlugin from "next-globe-gen/plugin";
const withNextGlobeGen = createNextGlobeGenPlugin();
const nextConfig: NextConfig = {
/* Next.js config options here */
};
export default withNextGlobeGen(nextConfig);
// @ts-check
import createNextGlobeGenPlugin from "next-globe-gen/plugin";
const withNextGlobeGen = createNextGlobeGenPlugin();
/** @type {import('next').NextConfig} */
const nextConfig: NextConfig = {
/* Next.js config options here */
};
export default withNextGlobeGen(nextConfig);
// @ts-check
const createNextGlobeGenPlugin = require("next-globe-gen/plugin");
const withNextGlobeGen = createNextGlobeGenPlugin();
/** @type {import('next').NextConfig} */
const nextConfig: NextConfig = {
/* Next.js config options here */
};
module.exports = withNextGlobeGen(nextConfig);
Parametersโ
createNextGlobeGenPlugin(configPath?: string);
Param | Type | Required | Description | Default |
---|---|---|---|---|
configPath | string | - | Path to a NextGlobeGen config file | ./i18n.config.ts |
Returnsโ
createNextGlobeGenPlugin
returns a function, which should be called with your Next.js config object. It returns the given config object with few added import aliases.