next-formatter 2.0.6 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # next-formatter
2
2
 
3
- Universal number, currency, date, and relative time formatter for Next.js App Router works in both **Server Components** and **Client Components** with zero hydration mismatches.
3
+ A universal formatter for numbers, currency, dates, and relative time - built for Next.js App Router, supporting **server components**, **client components**, and **Node.js backends**.
4
4
 
5
5
  [→ View Full Documentation](https://gauravgorade.github.io/next-formatter/)
6
6
 
@@ -32,20 +32,36 @@ export const getFormatter = () => _getFormatter(config);
32
32
 
33
33
  ## 1. Add the Provider
34
34
 
35
- Add `NextFormatterProvider` to your root layout.
35
+ Create a client wrapper component and add it to your root layout.
36
36
 
37
- **app/layout.tsx**
37
+ **app/providers/formatter-provider.tsx**
38
38
  ```tsx
39
- import { NextFormatterProvider } from "next-formatter/server";
39
+ "use client";
40
+
41
+ import { FormattersProvider } from "next-formatter/client";
40
42
  import { formatterConfig } from "@/lib/formatter";
43
+ import { ReactNode } from "react";
44
+
45
+ export function AppFormattersProvider({ children }: { children: ReactNode }) {
46
+ return (
47
+ <FormattersProvider config={formatterConfig}>
48
+ {children}
49
+ </FormattersProvider>
50
+ );
51
+ }
52
+ ```
53
+
54
+ **app/layout.tsx**
55
+ ```tsx
56
+ import { AppFormattersProvider } from "@/app/providers/formatter-provider";
41
57
 
42
- export default async function RootLayout({ children }) {
58
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
43
59
  return (
44
60
  <html lang="en">
45
61
  <body>
46
- <NextFormatterProvider config={formatterConfig}>
62
+ <AppFormattersProvider>
47
63
  {children}
48
- </NextFormatterProvider>
64
+ </AppFormattersProvider>
49
65
  </body>
50
66
  </html>
51
67
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-formatter",
3
- "version": "2.0.6",
3
+ "version": "2.2.0",
4
4
  "description": "A universal formatter for numbers, currency, dates, and relative time — built for Next.js App Router, supporting server components, client components, and Node.js backends.",
5
5
  "author": "gauravgorade",
6
6
  "license": "MIT",