@strata-sync/next 0.1.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/AGENTS.md +24 -0
- package/README.md +57 -0
- package/package.json +49 -0
- package/src/bootstrap.ts +624 -0
- package/src/client.ts +38 -0
- package/src/index.ts +45 -0
- package/src/prefetch.ts +155 -0
- package/src/provider.tsx +156 -0
- package/src/server.ts +29 -0
- package/tests/bootstrap.test.ts +377 -0
- package/tsconfig.json +28 -0
- package/vitest.config.ts +9 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @strata-sync/next
|
|
2
|
+
|
|
3
|
+
Next.js integration helpers for App Router and Server Components.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
- `npm run build` — compile TypeScript (`tsc`)
|
|
8
|
+
- `npm run dev` — watch mode (`tsc --watch`)
|
|
9
|
+
- `npm run test` — run tests (`vitest run`)
|
|
10
|
+
- `npm run lint` — lint with Biome
|
|
11
|
+
- `npm run check-types` — type check without emitting
|
|
12
|
+
|
|
13
|
+
## Gotchas
|
|
14
|
+
|
|
15
|
+
- Next.js 14 and 15 are both supported as peer dependencies — test compatibility when changing exports
|
|
16
|
+
- Package has separate entry points: default (client), `./client`, and `./server` — check `exports` in package.json
|
|
17
|
+
- Server exports must not import client-only code (React hooks, browser APIs)
|
|
18
|
+
- Client exports must include `"use client"` directive when using React hooks
|
|
19
|
+
|
|
20
|
+
## Conventions
|
|
21
|
+
|
|
22
|
+
- Server utilities go in `src/server/`, client utilities in `src/client/`
|
|
23
|
+
- Use Next.js App Router patterns — no Pages Router support
|
|
24
|
+
- Metadata helpers should use the App Router metadata API, not `next/head`
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @strata-sync/next
|
|
2
|
+
|
|
3
|
+
Next.js integration helpers for the Strata Sync with App Router support.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
sync-next bridges the sync engine with Next.js App Router patterns:
|
|
8
|
+
|
|
9
|
+
- **Server utilities** — server-side setup and initialization
|
|
10
|
+
- **Client utilities** — hooks and providers for client components
|
|
11
|
+
- **Metadata helpers** — integration with Next.js metadata API
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @strata-sync/next
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Peer dependencies: `next` ^14.0.0 || ^15.0.0, `react` ^18.0.0 || ^19.0.0
|
|
20
|
+
|
|
21
|
+
## Exports
|
|
22
|
+
|
|
23
|
+
The package has separate entry points for server and client code:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// Client components
|
|
27
|
+
import { /* client utilities */ } from "@strata-sync/next/client";
|
|
28
|
+
|
|
29
|
+
// Server components / route handlers
|
|
30
|
+
import { /* server utilities */ } from "@strata-sync/next/server";
|
|
31
|
+
|
|
32
|
+
// Default export (client-side)
|
|
33
|
+
import { /* default exports */ } from "@strata-sync/next";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
Use Server Components for initial data loading and Client Components for interactive sync features:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
// Server Component — fetch initial data
|
|
42
|
+
import { initSync } from "@strata-sync/next/server";
|
|
43
|
+
|
|
44
|
+
export default async function Page() {
|
|
45
|
+
const initialData = await initSync();
|
|
46
|
+
return <ClientApp initialData={initialData} />;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Client Component — use sync hooks
|
|
50
|
+
"use client";
|
|
51
|
+
import { useSyncClient } from "@strata-sync/next/client";
|
|
52
|
+
|
|
53
|
+
function ClientApp({ initialData }) {
|
|
54
|
+
const client = useSyncClient({ initialData });
|
|
55
|
+
// ...
|
|
56
|
+
}
|
|
57
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@strata-sync/next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/client.js",
|
|
9
|
+
"types": "./dist/client.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/client.d.ts",
|
|
13
|
+
"browser": "./dist/client.js",
|
|
14
|
+
"node": "./dist/server.js",
|
|
15
|
+
"default": "./dist/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./client": {
|
|
18
|
+
"types": "./dist/client.d.ts",
|
|
19
|
+
"import": "./dist/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"types": "./dist/server.d.ts",
|
|
23
|
+
"import": "./dist/server.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"lint": "biome lint .",
|
|
30
|
+
"check-types": "tsc --noEmit",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@strata-sync/core": "*",
|
|
35
|
+
"@strata-sync/client": "*",
|
|
36
|
+
"@strata-sync/react": "*"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/react": "^19.0.0",
|
|
40
|
+
"react": "^19.0.0",
|
|
41
|
+
"typescript": "^5.9.3",
|
|
42
|
+
"@biomejs/biome": "^2.3.12",
|
|
43
|
+
"vitest": "^4.0.18"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"next": "^14.0.0 || ^15.0.0",
|
|
47
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|