@mantis-core/next-core
v0.1.2
Published
Reusable Next.js providers and app-level runtime setup for Mantis Core.
Downloads
269
Maintainers
Readme
@mantis-core/next-core
Reusable Next.js app-level providers for Mantis Core apps.
Scope
- Query client creation.
- Session provider wiring.
- PrimeReact provider wiring.
- Toast provider wiring.
Out Of Scope
- Route/page business logic.
- Domain data fetching.
- UI components outside provider concerns.
Public API
createMantisCoreQueryClient(): QueryClient
type MantisCoreBaseProviderProps = PropsWithChildren<{
includeSessionProvider?: boolean;
includeToaster?: boolean;
queryClient?: QueryClient;
toasterProps?: ToasterProps;
}>;
MantisCoreBaseProvider(props)
type UseMantisToasts = {
addSuccessToast(...)
addErrorToast(...)
addInfoToast(...)
addWarningToast(...)
addLoadingToast(...)
promiseToast(...)
jsxToast(...)
dismiss(...)
remove(...)
}
useMantisToasts(): UseMantisToastsUsage Example
"use client";
import { MantisCoreBaseProvider } from "@mantis-core/next-core";
export default function Providers({ children }: { children: React.ReactNode }) {
return <MantisCoreBaseProvider>{children}</MantisCoreBaseProvider>;
}"use client";
import { useMantisToasts } from "@mantis-core/next-core";
export function Example() {
const toast = useMantisToasts();
return <button onClick={() => toast.addSuccessToast("Guardado")}>Toast</button>;
}Provider Behavior
- Creates a default
QueryClientunless one is injected. - Wraps children with
PrimeReactProvider. - Optionally includes
SessionProvider. - Optionally includes
react-hot-toastwith sane defaults. - Toast defaults use CSS tokens (
--card,--foreground,--border, semantic colors).
Build
pnpm --filter @mantis-core/next-core build
pnpm --filter @mantis-core/next-core typecheckPeer Dependencies
This package expects the consuming app to provide:
react,react-domnext-auth@tanstack/react-queryprimereactreact-hot-toast
