state-in-url 6.2.4 → 6.4.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.
- package/README.CN.md +4 -776
- package/README.es.md +836 -0
- package/README.fr.md +836 -0
- package/README.ja.md +836 -0
- package/{README.KO.md → README.ko.md} +69 -8
- package/README.md +34 -3
- package/README.pt-BR.md +836 -0
- package/README.ru.md +836 -0
- package/README.vi.md +836 -0
- package/README.zh-CN.md +836 -0
- package/dist/encoder/encoder.d.ts +1 -1
- package/dist/encoder/encoder.js +1 -1
- package/dist/encoder/encoder.mjs +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/next/useUrlState/useUrlState.d.ts +3 -3
- package/dist/next/useUrlState/useUrlState.js +1 -1
- package/dist/next/useUrlState/useUrlState.mjs +1 -1
- package/dist/package.json +34 -13
- package/dist/react-router/useUrlState/useUrlState.js +1 -1
- package/dist/react-router/useUrlState/useUrlState.mjs +1 -1
- package/dist/react-router6/useUrlState/useUrlState.js +1 -1
- package/dist/useInsertionEffect.js +1 -1
- package/dist/useLinkProps/hrefWithState.d.ts +3 -0
- package/dist/useLinkProps/hrefWithState.js +1 -0
- package/dist/useLinkProps/hrefWithState.mjs +1 -0
- package/dist/useLinkProps/index.d.ts +1 -0
- package/dist/useLinkProps/index.js +1 -0
- package/dist/useLinkProps/index.mjs +1 -0
- package/dist/useLinkProps/useLinkProps.d.ts +39 -0
- package/dist/useLinkProps/useLinkProps.js +1 -0
- package/dist/useLinkProps/useLinkProps.mjs +1 -0
- package/dist/useSharedState/useSharedState.d.ts +1 -1
- package/dist/useSharedState/useSharedState.js +1 -1
- package/dist/useSharedState/useSharedState.mjs +1 -1
- package/dist/useUrlEncode/useUrlEncode.js +1 -1
- package/dist/useUrlEncode/useUrlEncode.mjs +1 -1
- package/dist/useUrlStateBase/useUrlStateBase.d.ts +3 -3
- package/dist/useUrlStateBase/useUrlStateBase.js +1 -1
- package/dist/useUrlStateBase/useUrlStateBase.mjs +1 -1
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +34 -13
- package/skills/feature-state-hook/SKILL.md +36 -9
- package/skills/form-library-integration/SKILL.md +3 -4
- package/skills/input-handling/SKILL.md +20 -6
- package/skills/nextjs-ssr/SKILL.md +77 -9
- package/skills/react-router-remix-setup/SKILL.md +1 -1
- package/skills/shared-state-no-url/SKILL.md +1 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- i18n:start -->
|
|
2
|
+
[English](./README.md) · [简体中文](./README.zh-CN.md) · [日本語](./README.ja.md) · 한국어 · [Русский](./README.ru.md) · [Español](./README.es.md) · [Português (BR)](./README.pt-BR.md) · [Français](./README.fr.md) · [Tiếng Việt](./README.vi.md)
|
|
3
|
+
<!-- i18n:meta locale=ko source=README.md source-blob=bbf45a10aae9e88f68b27d84f51ee3e7e8a1e436 status=translated -->
|
|
4
|
+
<!-- i18n:end -->
|
|
2
5
|
|
|
3
6
|
<div align="center">
|
|
4
7
|
<img src="/packages/example-nextjs14/public/Logo_symbol.png" alt="state-in-url 로고" width="120px" />
|
|
@@ -11,6 +14,8 @@
|
|
|
11
14
|
|
|
12
15
|
<div align="center">
|
|
13
16
|
|
|
17
|
+
[](https://asmyshlyaev177.dev)
|
|
18
|
+
|
|
14
19
|
[](https://www.npmjs.com/package/state-in-url)
|
|
15
20
|

|
|
16
21
|
[](https://app.codacy.com/gh/asmyshlyaev177/state-in-url/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
@@ -23,6 +28,8 @@
|
|
|
23
28
|
[](https://scorecard.dev/viewer/?uri=github.com/asmyshlyaev177/state-in-url)
|
|
24
29
|
[](https://www.bestpractices.dev/projects/9679)
|
|
25
30
|
[](https://github.com/asmyshlyaev177/state-in-url/blob/master/LICENSE)
|
|
31
|
+
<!-- or by embedding this in your HTML:
|
|
32
|
+
<a href="https://www.bestpractices.dev/projects/9679"><img src="https://www.bestpractices.dev/projects/9679/badge"></a> -->
|
|
26
33
|
|
|
27
34
|
</div>
|
|
28
35
|
|
|
@@ -97,6 +104,8 @@ Next.js와 react-router용 `useUrlState` 훅과 그 외 JS 환경을 위한 헬
|
|
|
97
104
|
|
|
98
105
|
## 목차
|
|
99
106
|
|
|
107
|
+
<!-- toc:start -->
|
|
108
|
+
|
|
100
109
|
- [State in url](#state-in-url)
|
|
101
110
|
- [데모](#데모)
|
|
102
111
|
- [왜 `state-in-url`을 사용해야 하나요?](#왜-state-in-url을-사용해야-하나요)
|
|
@@ -106,6 +115,7 @@ Next.js와 react-router용 `useUrlState` 훅과 그 외 JS 환경을 위한 헬
|
|
|
106
115
|
- [설치](#설치)
|
|
107
116
|
- [1. 패키지 설치](#1-패키지-설치)
|
|
108
117
|
- [2. tsconfig.json 수정](#2-tsconfigjson-수정)
|
|
118
|
+
- [AI 코딩 에이전트와 함께 사용](#ai-코딩-에이전트와-함께-사용)
|
|
109
119
|
- [useUrlState](#useurlstate)
|
|
110
120
|
- [Next.js용 useUrlState 훅](#nextjs용-useurlstate-훅)
|
|
111
121
|
- [사용 예제](#사용-예제)
|
|
@@ -124,6 +134,7 @@ Next.js와 react-router용 `useUrlState` 훅과 그 외 JS 환경을 위한 헬
|
|
|
124
134
|
- [기타 훅과 헬퍼](#기타-훅과-헬퍼)
|
|
125
135
|
- [다른 라우터용 `useUrlStateBase` 훅](#다른-라우터용-useurlstatebase-훅)
|
|
126
136
|
- [React.js용 `useSharedState` 훅](#reactjs용-usesharedstate-훅)
|
|
137
|
+
- [React.js용 `useLinkProps` 훅](#reactjs용-uselinkprops-훅)
|
|
127
138
|
- [React.js용 `useUrlEncode` 훅](#reactjs용-useurlencode-훅)
|
|
128
139
|
- [`encodeState` 및 `decodeState` 헬퍼](#encodestate-및-decodestate-헬퍼)
|
|
129
140
|
- [`encode` 및 `decode` 헬퍼](#encode-및-decode-헬퍼)
|
|
@@ -136,9 +147,11 @@ Next.js와 react-router용 `useUrlState` 훅과 그 외 JS 환경을 위한 헬
|
|
|
136
147
|
- [변경 로그](#변경-로그)
|
|
137
148
|
- [언급](#언급)
|
|
138
149
|
- [라이선스](#라이선스)
|
|
139
|
-
- [
|
|
150
|
+
- [채용 문의](#채용-문의)
|
|
140
151
|
- [영감](#영감)
|
|
141
152
|
|
|
153
|
+
<!-- toc:end -->
|
|
154
|
+
|
|
142
155
|
## 설치
|
|
143
156
|
|
|
144
157
|
### 1. 패키지 설치
|
|
@@ -157,6 +170,16 @@ pnpm add state-in-url
|
|
|
157
170
|
`tsconfig.json`의 `compilerOptions`에서 `"moduleResolution": "Bundler"`, 또는 `"moduleResolution": "Node16"`, 또는 `"moduleResolution": "NodeNext"`로 설정하세요.
|
|
158
171
|
`"module": "ES2022"` 또는 `"module": "ESNext"` 설정이 필요할 수 있습니다.
|
|
159
172
|
|
|
173
|
+
## AI 코딩 에이전트와 함께 사용
|
|
174
|
+
|
|
175
|
+
`state-in-url`은 [@tanstack/intent](https://tanstack.com/intent/latest/docs/overview)용 스킬 파일을 함께 제공합니다. AI 에이전트(Claude Code, Cursor, Copilot, Codex 등)가 라이브러리를 사용할 때 올바른 패턴을 불러오고 흔한 실수를 피할 수 있습니다. `state-in-url`을 설치한 후 프로젝트에서 한 번 실행하세요:
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
npx @tanstack/intent@latest install
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
이렇게 하면 설치된 에이전트가 `node_modules/state-in-url/skills/`에서 스킬을 찾게 됩니다. 사용 가능한 스킬은 `npx @tanstack/intent@latest list`로 확인할 수 있습니다.
|
|
182
|
+
|
|
160
183
|
## useUrlState
|
|
161
184
|
|
|
162
185
|
초기 상태를 매개변수로 받아 상태 객체, URL 업데이트 콜백, 상태만 업데이트하는 콜백을 반환하는 메인 훅입니다.
|
|
@@ -214,7 +237,7 @@ function MyComponent() {
|
|
|
214
237
|
/>
|
|
215
238
|
|
|
216
239
|
<button onClick={() => setUrl((_, initial) => initial)}>
|
|
217
|
-
|
|
240
|
+
Reset
|
|
218
241
|
</button>
|
|
219
242
|
|
|
220
243
|
</div>
|
|
@@ -360,7 +383,7 @@ function TagsComponent() {
|
|
|
360
383
|
|
|
361
384
|
return (
|
|
362
385
|
<div>
|
|
363
|
-
<Field text="
|
|
386
|
+
<Field text="Tags">
|
|
364
387
|
<div className="flex flex-wrap gap-2">
|
|
365
388
|
{tags.map((tag) => (
|
|
366
389
|
<Tag
|
|
@@ -448,7 +471,7 @@ function TagsComponent() {
|
|
|
448
471
|
|
|
449
472
|
return (
|
|
450
473
|
<div>
|
|
451
|
-
<Field text="
|
|
474
|
+
<Field text="Tags">
|
|
452
475
|
<div className="flex flex-wrap gap-2">
|
|
453
476
|
{tags.map((tag) => (
|
|
454
477
|
<Tag
|
|
@@ -583,7 +606,7 @@ function TagsComponent() {
|
|
|
583
606
|
|
|
584
607
|
return (
|
|
585
608
|
<div>
|
|
586
|
-
<Field text="
|
|
609
|
+
<Field text="Tags">
|
|
587
610
|
<div className="flex flex-wrap gap-2">
|
|
588
611
|
{tags.map((tag) => (
|
|
589
612
|
<Tag
|
|
@@ -672,6 +695,29 @@ function SettingsComponent() {
|
|
|
672
695
|
|
|
673
696
|
[API 문서](packages/urlstate/useSharedState/README.md)
|
|
674
697
|
|
|
698
|
+
### React.js용 `useLinkProps` 훅
|
|
699
|
+
|
|
700
|
+
다른 라우트를 가리키는 링크로 상태를 넘기는 훅입니다. 예를 들어 언어 전환기에 씁니다. `setUrl` 은 언제나 현재 경로에 쓰지만, 이 훅은 그렇지 않습니다.
|
|
701
|
+
|
|
702
|
+
```tsx
|
|
703
|
+
'use client'
|
|
704
|
+
import Link from 'next/link';
|
|
705
|
+
import { useRouter } from 'next/navigation';
|
|
706
|
+
import { useLinkProps } from 'state-in-url/useLinkProps';
|
|
707
|
+
|
|
708
|
+
export const form = { name: '' };
|
|
709
|
+
|
|
710
|
+
function LanguagePicker() {
|
|
711
|
+
const linkProps = useLinkProps(form, useRouter().push);
|
|
712
|
+
|
|
713
|
+
return <Link {...linkProps('/de/pricing')}>Deutsch</Link>;
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
마크업에는 원래의 `href` 가 남으므로 크롤러와 `hreflang` 은 정규 URL 을 봅니다. 상태는 클릭할 때 읽습니다.
|
|
718
|
+
|
|
719
|
+
[API 문서](packages/urlstate/useLinkProps/README.ko.md)
|
|
720
|
+
|
|
675
721
|
### React.js용 `useUrlEncode` 훅
|
|
676
722
|
|
|
677
723
|
[API 문서](packages/urlstate/useUrlEncode/README.md)
|
|
@@ -755,9 +801,24 @@ export const useUserState = () => {
|
|
|
755
801
|
|
|
756
802
|
이 프로젝트는 [MIT 라이선스](LICENSE)에 따라 라이선스가 부여됩니다.
|
|
757
803
|
|
|
758
|
-
##
|
|
804
|
+
## 채용 문의
|
|
805
|
+
|
|
806
|
+
저는 **Aleksandr Smyshliaev**입니다. 이 라이브러리의 단독 작성자이자 유지보수자입니다.
|
|
807
|
+
시니어 프론트엔드 엔지니어(React / Next.js / TypeScript, 8년 이상)이며, 현재 **풀타임 원격 근무를 찾고 있습니다**.
|
|
808
|
+
|
|
809
|
+
이 라이브러리는 제가 잘하는 것을 간추린 것입니다. 지저분한 브라우저 프리미티브 위의 타입 안전 API, 의존성 없음, 여러 React 메이저 버전을 거친 Next.js, Remix, React Router 전반의 안정성입니다.
|
|
759
810
|
|
|
760
|
-
|
|
811
|
+
- **특기** — 리팩터링에도 살아남는 컴포넌트 라이브러리, 상태 관리, 테스트 스위트.
|
|
812
|
+
- **다른 프로젝트** —
|
|
813
|
+
[react-horizontal-scrolling-menu](https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu)
|
|
814
|
+
(주간 약 84k 설치),
|
|
815
|
+
[test-proxy-recorder](https://github.com/asmyshlyaev177/test-proxy-recorder)
|
|
816
|
+
(Playwright용 record/replay),
|
|
817
|
+
[llm-queue](https://github.com/asmyshlyaev177/llm-queue).
|
|
818
|
+
- **위치** — 조지아 트빌리시(GMT+4). CET와 완전히 겹칩니다. 계약 사업자로 등록되어 있어 B2B 계약에 employer-of-record 설정이 필요 없습니다.
|
|
819
|
+
- **연락처** — [asmyshlyaev177.dev](https://asmyshlyaev177.dev) ·
|
|
820
|
+
[asmyshlyaev177@gmail.com](mailto:asmyshlyaev177@gmail.com) ·
|
|
821
|
+
[LinkedIn](https://linkedin.com/in/asmyshlyaev177) · Telegram @asmyshlyaev177
|
|
761
822
|
|
|
762
823
|
## 영감
|
|
763
824
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- i18n:start -->
|
|
2
|
+
English · [简体中文](./README.zh-CN.md) · [日本語](./README.ja.md) · [한국어](./README.ko.md) · [Русский](./README.ru.md) · [Español](./README.es.md) · [Português (BR)](./README.pt-BR.md) · [Français](./README.fr.md) · [Tiếng Việt](./README.vi.md)
|
|
3
|
+
<!-- i18n:meta locale=en -->
|
|
4
|
+
<!-- i18n:end -->
|
|
2
5
|
|
|
3
6
|
<div align="center">
|
|
4
7
|
<img src="/packages/example-nextjs14/public/Logo_symbol.png" alt="state-in-url logo" width="120px" />
|
|
@@ -101,6 +104,8 @@ This library is a good alternative for NUQS.
|
|
|
101
104
|
|
|
102
105
|
## Table of content
|
|
103
106
|
|
|
107
|
+
<!-- toc:start -->
|
|
108
|
+
|
|
104
109
|
- [State in url](#state-in-url)
|
|
105
110
|
- [Demo](#demo)
|
|
106
111
|
- [Why use `state-in-url`?](#why-use-state-in-url)
|
|
@@ -129,6 +134,7 @@ This library is a good alternative for NUQS.
|
|
|
129
134
|
- [Other hooks and helpers](#other-hooks-and-helpers)
|
|
130
135
|
- [`useUrlStateBase` hook for others routers](#useurlstatebase-hook-for-others-routers)
|
|
131
136
|
- [`useSharedState` hook for React.js](#usesharedstate-hook-for-reactjs)
|
|
137
|
+
- [`useLinkProps` hook for React.js](#uselinkprops-hook-for-reactjs)
|
|
132
138
|
- [`useUrlEncode` hook for React.js](#useurlencode-hook-for-reactjs)
|
|
133
139
|
- [`encodeState` and `decodeState` helpers](#encodestate-and-decodestate-helpers)
|
|
134
140
|
- [`encode` and `decode` helpers](#encode-and-decode-helpers)
|
|
@@ -137,13 +143,15 @@ This library is a good alternative for NUQS.
|
|
|
137
143
|
- [Other](#other)
|
|
138
144
|
- [Contribute and/or run locally](#contribute-andor-run-locally)
|
|
139
145
|
- [Roadmap](#roadmap)
|
|
140
|
-
- [Contact
|
|
146
|
+
- [Contact & Support](#contact--support)
|
|
141
147
|
- [Changelog](#changelog)
|
|
142
148
|
- [Mentions](#mentions)
|
|
143
149
|
- [License](#license)
|
|
144
|
-
- [
|
|
150
|
+
- [Hire me](#hire-me)
|
|
145
151
|
- [Inspiration](#inspiration)
|
|
146
152
|
|
|
153
|
+
<!-- toc:end -->
|
|
154
|
+
|
|
147
155
|
## installation
|
|
148
156
|
|
|
149
157
|
### 1. Install package
|
|
@@ -691,6 +699,29 @@ function SettingsComponent() {
|
|
|
691
699
|
|
|
692
700
|
[API Docs](packages/urlstate/useSharedState/README.md)
|
|
693
701
|
|
|
702
|
+
### `useLinkProps` hook for React.js
|
|
703
|
+
|
|
704
|
+
Hook to carry the state to a link pointing at a different route, e.g. a language switcher. `setUrl` always writes to the current path; this doesn't.
|
|
705
|
+
|
|
706
|
+
```tsx
|
|
707
|
+
'use client'
|
|
708
|
+
import Link from 'next/link';
|
|
709
|
+
import { useRouter } from 'next/navigation';
|
|
710
|
+
import { useLinkProps } from 'state-in-url/useLinkProps';
|
|
711
|
+
|
|
712
|
+
export const form = { name: '' };
|
|
713
|
+
|
|
714
|
+
function LanguagePicker() {
|
|
715
|
+
const linkProps = useLinkProps(form, useRouter().push);
|
|
716
|
+
|
|
717
|
+
return <Link {...linkProps('/de/pricing')}>Deutsch</Link>;
|
|
718
|
+
}
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
The markup keeps the plain `href`, so crawlers and `hreflang` see the canonical URL; the state is read on click.
|
|
722
|
+
|
|
723
|
+
[API Docs](packages/urlstate/useLinkProps/README.md)
|
|
724
|
+
|
|
694
725
|
### `useUrlEncode` hook for React.js
|
|
695
726
|
|
|
696
727
|
[API Docs](packages/urlstate/useUrlEncode/README.md)
|