You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/src/content/docs/integrations/preact-ssr.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ The SSR plugin can provide request-bound browser-like dependencies for stores th
118
118
119
119
Use `inject.cookieStore: true` when the renderer should provide a request-bound `CookieStore$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. See [SSR Cookies](/ssr/cookies) for the full setup, including store code and `Set-Cookie` forwarding.
120
120
121
-
```js
121
+
```js title="vite.config.js"
122
122
ssr({
123
123
index:'src/index.tsx',
124
124
inject: {
@@ -131,7 +131,7 @@ ssr({
131
131
132
132
Use `inject.browserLocale: true` when the renderer should provide request-bound `Locales$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer parses the incoming `Accept-Language` header with [`parseLocales`](/platform/web/#locale), so universal stores can inject `Locales$` and resolve the same locale shape on the server and in the browser. See [SSR Locale](/ssr/locale) for the full setup.
133
133
134
-
```js
134
+
```js title="vite.config.js"
135
135
ssr({
136
136
index:'src/index.tsx',
137
137
inject: {
@@ -144,7 +144,7 @@ ssr({
144
144
145
145
Use `inject.userAgent: true` when the renderer should provide request-bound `UserAgent$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer reads the incoming `User-Agent` header, so universal stores can inject `UserAgent$` and read a user agent string on the server and in the browser.
Copy file name to clipboardExpand all lines: website/src/content/docs/integrations/react-ssr.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ The SSR plugin can provide request-bound browser-like dependencies for stores th
118
118
119
119
Use `inject.cookieStore: true` when the renderer should provide a request-bound `CookieStore$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. See [SSR Cookies](/ssr/cookies) for the full setup, including store code and `Set-Cookie` forwarding.
120
120
121
-
```js
121
+
```js title="vite.config.js"
122
122
ssr({
123
123
index:'src/index.ts',
124
124
inject: {
@@ -131,7 +131,7 @@ ssr({
131
131
132
132
Use `inject.browserLocale: true` when the renderer should provide request-bound `Locales$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer parses the incoming `Accept-Language` header with [`parseLocales`](/platform/web/#locale), so universal stores can inject `Locales$` and resolve the same locale shape on the server and in the browser. See [SSR Locale](/ssr/locale) for the full setup.
133
133
134
-
```js
134
+
```js title="vite.config.js"
135
135
ssr({
136
136
index:'src/index.ts',
137
137
inject: {
@@ -144,7 +144,7 @@ ssr({
144
144
145
145
Use `inject.userAgent: true` when the renderer should provide request-bound `UserAgent$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer reads the incoming `User-Agent` header, so universal stores can inject `UserAgent$` and read a user agent string on the server and in the browser.
Copy file name to clipboardExpand all lines: website/src/content/docs/integrations/svelte-ssr.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ The SSR plugin can provide request-bound browser-like dependencies for stores th
118
118
119
119
Use `inject.cookieStore: true` when the renderer should provide a request-bound `CookieStore$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. See [SSR Cookies](/ssr/cookies) for the full setup, including store code and `Set-Cookie` forwarding.
120
120
121
-
```js
121
+
```js title="vite.config.js"
122
122
ssr({
123
123
index:'src/index.ts',
124
124
inject: {
@@ -131,7 +131,7 @@ ssr({
131
131
132
132
Use `inject.browserLocale: true` when the renderer should provide request-bound `Locales$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer parses the incoming `Accept-Language` header with [`parseLocales`](/platform/web/#locale), so universal stores can inject `Locales$` and resolve the same locale shape on the server and in the browser. See [SSR Locale](/ssr/locale) for the full setup.
133
133
134
-
```js
134
+
```js title="vite.config.js"
135
135
ssr({
136
136
index:'src/index.ts',
137
137
inject: {
@@ -144,7 +144,7 @@ ssr({
144
144
145
145
Use `inject.userAgent: true` when the renderer should provide request-bound `UserAgent$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer reads the incoming `User-Agent` header, so universal stores can inject `UserAgent$` and read a user agent string on the server and in the browser.
Copy file name to clipboardExpand all lines: website/src/content/docs/ssr/index.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,7 +193,7 @@ The SSR plugin can provide request-bound browser-like dependencies for stores th
193
193
194
194
Use `inject.cookieStore:true` when the renderer should provide a request-bound `CookieStore$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. See [SSR Cookies](/ssr/cookies) for the full setup, including store code and `Set-Cookie` forwarding.
195
195
196
-
```js
196
+
```js title="vite.config.js"
197
197
ssr({
198
198
index:'src/index.js',
199
199
inject: {
@@ -206,7 +206,7 @@ ssr({
206
206
207
207
Use `inject.browserLocale:true` when the renderer should provide request-bound `Locales$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer parses the incoming `Accept-Language` header with [`parseLocales`](/platform/web/#locale), so universal stores can inject `Locales$` and resolve the same locale shape on the server and in the browser. See [SSR Locale](/ssr/locale) for the full setup.
208
208
209
-
```js
209
+
```js title="vite.config.js"
210
210
ssr({
211
211
index:'src/index.js',
212
212
inject: {
@@ -219,7 +219,7 @@ ssr({
219
219
220
220
Use `inject.userAgent:true` when the renderer should provide request-bound `UserAgent$` during SSR. This feature uses the optional peer package `@nano_kit/platform-web`, so install it in the app before enabling the option. The renderer reads the incoming `User-Agent` header, so universal stores can inject `UserAgent$` and read a user agent string on the server and in the browser.
Copy file name to clipboardExpand all lines: website/src/content/docs/tutorial/api-services.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ As an app grows, API calls tend to spread. Every request repeats the same transp
9
9
10
10
In our example, the stores are injectable factories now, but the API layer is still a set of standalone functions:
11
11
12
-
```ts title="services/events.ts"
12
+
```ts title="src/services/events.ts"
13
13
exportasyncfunction fetchEvent(slug:string) {
14
14
const response =awaitfetch(`/api/events/${slug}`)
15
15
@@ -43,7 +43,7 @@ The class itself is the DI token. The first `inject(EventsService$)` call create
43
43
44
44
The transport differs between the browser and the server, so it gets two implementations behind one interface. The browser one stays relative to the page origin:
@@ -99,7 +99,7 @@ export class UserService$ extends Injectable$ {
99
99
100
100
The session state is just a query: `GET /api/users/me` keyed as `UserKey`. For an anonymous visitor the query fails with `UserError.Unauthenticated`, and that error code *is* the "logged out" state.
The layout shows who is logged in. Including `$user` in the layout `Stores$` means SSR waits for the session before rendering, so the name appears in the first HTML response:
281
281
282
-
```tsx title="ui/pages/Layout.tsx"
282
+
```tsx title="src/ui/pages/Layout.tsx"
283
283
exportfunction Stores$() {
284
284
const { $user } =inject(User$)
285
285
@@ -317,7 +317,7 @@ The renderer can provide the incoming request cookies to stores and services. Ad
317
317
pnpm add @nano_kit/platform-web
318
318
```
319
319
320
-
```ts
320
+
```ts title="vite.config.ts"
321
321
ssr({
322
322
index: 'src/index.tsx',
323
323
server: 'src/server.ts',
@@ -329,7 +329,7 @@ ssr({
329
329
330
330
Now `CookieStore$` is injectable during SSR, and the server transport from the API services chapter gets its promised upgrade — it forwards the session cookie to the API:
@@ -390,7 +390,7 @@ See [SSR Cookies](/ssr/cookies) for the full picture of request-bound cookie sto
390
390
391
391
With a session, RSVP stops being an anonymous counter. The API toggles attendance per user and returns a `going` flag, so `BoardEvent` grows one field:
392
392
393
-
```ts
393
+
```ts title="src/services/events.ts"
394
394
exportinterfaceBoardEvent {
395
395
/* ... */
396
396
attendees:number
@@ -400,7 +400,7 @@ export interface BoardEvent {
400
400
401
401
The optimistic update from the optimistic updates chapter becomes a toggle. Setting cache data returns a revert callback, so rolling back on error takes one line:
402
402
403
-
```ts title="stores/events.ts"
403
+
```ts title="src/stores/events.ts"
404
404
exportfunction RsvpEvent$() {
405
405
const eventsService =inject(EventsService$)
406
406
const { $user } =inject(User$)
@@ -435,7 +435,7 @@ export function RsvpEvent$() {
435
435
436
436
A logged in user toggles `going` in both directions; an anonymous visitor still just adds a guest, so `going` stays `false` for them. The event page picks the button label from the flag:
@@ -47,7 +47,7 @@ Nano Kit solves that by combining store signals for local form values with query
47
47
48
48
Form input values are local UI state, so plain store [`signal`](/store/core-concepts#signals-and-effects) values are enough. Derived values like validation errors and request payload can be computed from those signals.
49
49
50
-
```ts
50
+
```ts title="src/stores/newEvent.ts"
51
51
import { action, computed, signal } from'@nano_kit/store'
0 commit comments