Skip to content

Commit b7a560e

Browse files
authored
Merge pull request #12 from alexdln/nc-11
nc-11 refactor package and example
2 parents e063817 + fdcd29b commit b7a560e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1025
-1172
lines changed

.github/workflows/auto-tests.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@ name: Test package
33
on:
44
schedule:
55
- cron: "0 */6 * * *"
6+
workflow_dispatch:
67

78
jobs:
89
test:
910
runs-on: ubuntu-latest
1011

1112
steps:
1213
- name: Checkout code
13-
uses: actions/checkout@v4
14+
uses: actions/checkout@v5
1415

1516
- name: Set up Node.js
16-
uses: actions/setup-node@v3
17+
uses: actions/setup-node@v6
1718
with:
18-
node-version: "20"
19+
node-version: "24"
1920

2021
- name: Install pnpm
21-
uses: pnpm/action-setup@v3
22-
with:
23-
version: 8
22+
uses: pnpm/action-setup@v4
2423

2524
- name: Install dependencies and build package
2625
run: |

.github/workflows/npm-publish.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@ jobs:
1010

1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414

1515
- name: Set up Node.js
16-
uses: actions/setup-node@v3
16+
uses: actions/setup-node@v6
1717
with:
18-
node-version: '20'
18+
node-version: "24"
1919

2020
- name: Install pnpm
21-
uses: pnpm/action-setup@v3
22-
with:
23-
version: 8
21+
uses: pnpm/action-setup@v4
2422

2523
- name: Install dependencies and build
2624
run: |
@@ -42,6 +40,7 @@ jobs:
4240
if: "!contains(github.ref_name, 'canary')"
4341
run: |
4442
npm set //registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}
43+
npm version --no-git-tag-version ${{github.ref_name}}
4544
npm publish --access public
4645
working-directory: ./package
4746

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)

examples/isomorphic-context/app/[locale]/page.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/isomorphic-context/app/layout.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/isomorphic-context/app/page.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/isomorphic-context/components/ClientBlock/index.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/isomorphic-context/components/ClientContext/index.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/isomorphic-context/components/ClientContextProvider/index.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)