UNPKG

@envkit/nextjs

Version:

Environment variable management for Next.js applications

100 lines (99 loc) 3.14 kB
import React, { ReactNode } from 'react'; export interface EnvVarInfo { key: string; value?: string; description?: string; label?: string; secret?: boolean; placeholder?: string; } export type MissingVar = EnvVarInfo; export type OnFallbackSubmit = () => void; export interface FallbackUIProps { missingVars: MissingVar[]; isLoading: boolean; onSubmit: OnFallbackSubmit; /** * Optional logo URL to display instead of the default Onboardbase logo */ logoUrl?: string; /** * Optional title to display at the top of the form */ title?: string; /** * Optional description text to display below the title */ description?: string; /** * When true, all environment variables will be masked by default * Users can toggle visibility for individual variables */ maskAllEnvs?: boolean; /** * When true, users cannot add new environment variables * Only the required variables will be shown */ disableAddNew?: boolean; } interface EnvKitProviderProps { /** * React children */ children: ReactNode; /** * Environment variables that are required for the application to run * This is only needed on the backend side and is optional in the component props * @deprecated This prop is only needed on the backend side */ requiredVars?: string[]; /** * Path to redirect to when environment variables are missing * @default '/env-setup' */ fallbackPath?: string; /** * Whether the application is running in production mode * @default process.env.NODE_ENV === 'production' */ isProduction?: boolean; /** * Optional URL to a logo to display in the fallback UI */ logoUrl?: string; /** * Optional title to display at the top of the fallback UI */ title?: string; /** * Optional description to display below the title in the fallback UI */ description?: string; /** * Custom component to render when environment variables are missing * @default DefaultFallbackUI */ customFallbackUI?: React.ComponentType<FallbackUIProps>; /** * Callback when missing vars are detected */ onMissingVars?: (missingVars: string[]) => void; /** * When true, all environment variables will be masked by default * Users can toggle visibility for individual variables * @default false */ maskAllEnvs?: boolean; /** * When true, users cannot add new environment variables * Only the required variables will be shown * @default false */ disableAddNew?: boolean; } /** * EnvKitProvider component that wraps the application and handles missing environment variables * Compatible with Next.js and App Router */ export declare function EnvKitProvider({ children, requiredVars, fallbackPath, isProduction, customFallbackUI: CustomFallbackUI, logoUrl, title, description, onMissingVars, maskAllEnvs, disableAddNew, }: EnvKitProviderProps): import("react/jsx-runtime").JSX.Element; export default EnvKitProvider;