Skip to content

Commit 2d8f64e

Browse files
committed
nc-11 update readme
1 parent d7c4239 commit 2d8f64e

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Alexander Savelyev <vordgi1@gmail.com>
3+
Copyright (c) 2025 Alex Savelyev <dev@alexdln.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,37 @@ npm i @nimpl/context
2020
yarn add @nimpl/context
2121
```
2222

23+
## Usage
24+
25+
```tsx
26+
// stores/app-store/contexts.server.tsx
27+
import createServerContext from "@nimpl/context/create-server-context";
28+
export const AppServerContext = createServerContext<{ data: string | null }>({
29+
data: null,
30+
});
31+
32+
// components/parent-component
33+
import { AppServerContext } from "@/stores/app-store/contexts.server";
34+
import { ChildComponent } from "./child-component";
35+
36+
export const ParentComponent = () => (
37+
{/* Same as <AppServerContext.Provider /> */}
38+
<AppServerContext value={{ data: "test" }}>
39+
<ChildComponent />
40+
</AppServerContext>
41+
);
42+
43+
// components/child-component
44+
import getServerContext from "@nimpl/context/get-server-context";
45+
import { AppServerContext } from "@/stores/app-store/contexts.server";
46+
47+
export const ChildComponent = () => {
48+
const context = getServerContext(AppServerContext);
49+
50+
return <div>{context.data}</div>;
51+
};
52+
```
53+
2354
## Stability
2455

2556
All context are covered with tests. Tests are run on every release and every 6 hours on the latest **Canary** version of `Next.js`.
@@ -28,7 +59,7 @@ In this way, you can be sure not only of the stability of the code, but also tha
2859

2960
## Examples
3061

31-
You can see examples in the [directory](https://github.com/vordgi/nimpl-context/tree/main/examples) of the repository.
62+
You can see examples in the [directory](https://github.com/alexdln/nimpl-context/tree/main/examples) of the repository.
3263

3364
## Additional
3465

@@ -38,4 +69,4 @@ Create issues for identified issues, desired getters, or various improvements.
3869

3970
## License
4071

41-
[MIT](https://github.com/vordgi/nimpl-context/blob/main/LICENSE)
72+
[MIT](https://github.com/alexdln/nimpl-context/blob/main/LICENSE)

0 commit comments

Comments
 (0)