diff --git a/examples/streaming/components/Counter.tsx b/examples/basic/components/Counter.tsx
similarity index 100%
rename from examples/streaming/components/Counter.tsx
rename to examples/basic/components/Counter.tsx
index 0bdf242f..a3c5747c 100644
--- a/examples/streaming/components/Counter.tsx
+++ b/examples/basic/components/Counter.tsx
@@ -1,7 +1,7 @@
-import React, { useState } from 'react'
-
export { Counter }
+import React, { useState } from 'react'
+
function Counter() {
const [count, setCount] = useState(0)
return (
diff --git a/examples/basic/layouts/LayoutDefault.tsx b/examples/basic/layouts/LayoutDefault.tsx
index 90efefba..5a0a7496 100644
--- a/examples/basic/layouts/LayoutDefault.tsx
+++ b/examples/basic/layouts/LayoutDefault.tsx
@@ -18,6 +18,7 @@ function LayoutDefault({ children }: { children: React.ReactNode }) {
Welcome
Data Fetching
+ HTML Streaming
{children}
diff --git a/examples/basic/layouts/style.css b/examples/basic/layouts/style.css
index 7afa4ca5..65bc4cba 100644
--- a/examples/basic/layouts/style.css
+++ b/examples/basic/layouts/style.css
@@ -27,3 +27,11 @@ body {
body.page-is-transitioning #page-content {
opacity: 0;
}
+
+/* Inline code blocks */
+code {
+ font-family: monospace;
+ background-color: #eaeaea;
+ padding: 3px 5px;
+ border-radius: 4px;
+}
diff --git a/examples/basic/package.json b/examples/basic/package.json
index 3115f427..4bc57af1 100644
--- a/examples/basic/package.json
+++ b/examples/basic/package.json
@@ -2,7 +2,7 @@
"scripts": {
"dev": "vite dev",
"build": "vite build",
- "preview": "vite preview",
+ "preview": "vite build && vite preview",
"test": "tsc --noEmit"
},
"dependencies": {
@@ -12,6 +12,7 @@
"node-fetch": "^3.3.2",
"react": "18.2.0",
"react-dom": "18.2.0",
+ "react-streaming": "^0.3.22",
"typescript": "^5.3.3",
"vike": "^0.4.168",
"vike-react": "^0.4.6",
diff --git a/examples/basic/pages/+config.ts b/examples/basic/pages/+config.ts
index 7f224b9a..05750e8e 100644
--- a/examples/basic/pages/+config.ts
+++ b/examples/basic/pages/+config.ts
@@ -11,5 +11,7 @@ const config = {
Head: HeadDefault,
//
title: 'My Vike + React App',
+ // Enable HTML streaming (https://vike.dev/stream)
+ stream: true,
extends: vikeReact
} satisfies Config
diff --git a/examples/basic/pages/index/+Page.tsx b/examples/basic/pages/index/+Page.tsx
index 75b3dbbe..ffe17d86 100644
--- a/examples/basic/pages/index/+Page.tsx
+++ b/examples/basic/pages/index/+Page.tsx
@@ -1,7 +1,7 @@
export default Page
import React from 'react'
-import { Counter } from './Counter'
+import { Counter } from '../../components/Counter'
function Page() {
return (
diff --git a/examples/basic/pages/index/Counter.tsx b/examples/basic/pages/index/Counter.tsx
deleted file mode 100644
index 70fe5fbb..00000000
--- a/examples/basic/pages/index/Counter.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-export { Counter }
-
-import React, { useState } from 'react'
-
-function Counter() {
- const [count, setCount] = useState(0)
-
- return setCount((count) => count + 1)}>Counter {count}
-}
diff --git a/examples/streaming/pages/index/+Page.tsx b/examples/basic/pages/streaming/+Page.tsx
similarity index 70%
rename from examples/streaming/pages/index/+Page.tsx
rename to examples/basic/pages/streaming/+Page.tsx
index 82638340..d8a15847 100644
--- a/examples/streaming/pages/index/+Page.tsx
+++ b/examples/basic/pages/streaming/+Page.tsx
@@ -1,14 +1,18 @@
export default Page
-import React, { Suspense, useState } from 'react'
+import React, { Suspense } from 'react'
import { useAsync } from 'react-streaming'
import { Counter } from '../../components/Counter'
function Page() {
- const [count, setCount] = useState(0)
return (
<>
Star Wars Movies
+
+ Same as /star-wars
page, but showcasing HTML Streaming and{' '}
+ Progressive Rendering (note how the counter is
+ interactive before the data has finished loading).
+
Loading...}>
diff --git a/examples/basic/readme.md b/examples/basic/readme.md
index 23de22af..e0719233 100644
--- a/examples/basic/readme.md
+++ b/examples/basic/readme.md
@@ -1,10 +1,9 @@
-Basic example of using `vike-react`, showcasing:
+Full-fledged example of using `vike-react`, showcasing:
-* [layouts](https://vike.dev/layouts)
-* rendering to ``
-* fetching data with [`data()`](https://vike.dev/data) hooks
-* [configs](https://vike.dev/config)
-* [error pages](https://vike.dev/error-page)
+- [Layout](https://vike.dev/Layout)
+- Fetching data with [`data()`](https://vike.dev/data)
+- [Error page](https://vike.dev/error-page)
+- [HTML Streaming](https://vike.dev/streaming)
```bash
git clone git@github.com:vikejs/vike-react
diff --git a/examples/streaming/.gitignore b/examples/streaming/.gitignore
deleted file mode 100644
index b0a5c349..00000000
--- a/examples/streaming/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/node_modules/
-/dist/
diff --git a/examples/streaming/assets/logo.svg b/examples/streaming/assets/logo.svg
deleted file mode 100644
index 94d3caa0..00000000
--- a/examples/streaming/assets/logo.svg
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- image/svg+xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/streaming/components/Link.tsx b/examples/streaming/components/Link.tsx
deleted file mode 100644
index 3bb18237..00000000
--- a/examples/streaming/components/Link.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-export { Link }
-
-import { usePageContext } from 'vike-react/usePageContext'
-import React from 'react'
-
-function Link({ href, children }: { href: string; children: string }) {
- const pageContext = usePageContext()
- const { urlPathname } = pageContext
- const isActive = href === '/' ? urlPathname === href : urlPathname.startsWith(href)
- return (
-
- {children}
-
- )
-}
diff --git a/examples/streaming/layouts/HeadDefault.tsx b/examples/streaming/layouts/HeadDefault.tsx
deleted file mode 100644
index ef374b88..00000000
--- a/examples/streaming/layouts/HeadDefault.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-export default HeadDefault
-
-import React from 'react'
-import logoUrl from '../assets/logo.svg'
-
-function HeadDefault() {
- return (
- <>
-
-
-
- >
- )
-}
diff --git a/examples/streaming/layouts/LayoutDefault.tsx b/examples/streaming/layouts/LayoutDefault.tsx
deleted file mode 100644
index f8e8f39a..00000000
--- a/examples/streaming/layouts/LayoutDefault.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-export default LayoutDefault
-
-import './style.css'
-import React from 'react'
-import logoUrl from '../assets/logo.svg'
-import { Link } from '../components/Link'
-
-function LayoutDefault({ children }: { children: React.ReactNode }) {
- return (
-
-
-
- Home
-
- {children}
-
- )
-}
-
-function Sidebar({ children }: { children: React.ReactNode }) {
- return (
-
- )
-}
-
-function Content({ children }: { children: React.ReactNode }) {
- return (
-
- )
-}
-
-function Logo() {
- return (
-
- )
-}
diff --git a/examples/streaming/layouts/style.css b/examples/streaming/layouts/style.css
deleted file mode 100644
index 7afa4ca5..00000000
--- a/examples/streaming/layouts/style.css
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Links */
-a {
- text-decoration: none;
-}
-#sidebar a {
- padding: 2px 10px;
- margin-left: -10px;
-}
-#sidebar a.is-active {
- background-color: #eee;
-}
-
-/* Reset */
-body {
- margin: 0;
- font-family: sans-serif;
-}
-* {
- box-sizing: border-box;
-}
-
-/* Page Transition Anmiation */
-#page-content {
- opacity: 1;
- transition: opacity 0.3s ease-in-out;
-}
-body.page-is-transitioning #page-content {
- opacity: 0;
-}
diff --git a/examples/streaming/package.json b/examples/streaming/package.json
deleted file mode 100644
index 202b062f..00000000
--- a/examples/streaming/package.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "scripts": {
- "dev": "vite dev",
- "build": "vite build",
- "preview": "vite build && vite preview",
- "test": "tsc --noEmit"
- },
- "dependencies": {
- "@types/react": "^18.2.55",
- "@types/react-dom": "^18.2.19",
- "@vitejs/plugin-react": "^4.2.1",
- "react": "18.2.0",
- "react-dom": "18.2.0",
- "react-streaming": "^0.3.22",
- "typescript": "^5.3.3",
- "vike": "^0.4.168",
- "vike-react": "^0.4.6",
- "vite": "^5.1.1"
- },
- "type": "module"
-}
diff --git a/examples/streaming/pages/+config.ts b/examples/streaming/pages/+config.ts
deleted file mode 100644
index 81f8b343..00000000
--- a/examples/streaming/pages/+config.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import type { Config } from 'vike/types'
-import Layout from '../layouts/LayoutDefault'
-import Head from '../layouts/HeadDefault'
-import vikeReact from 'vike-react/config'
-
-// Default configs (can be overridden by pages)
-export default {
- Layout,
- Head,
- //
- title: 'My Vike + React App',
- stream: true,
- extends: vikeReact
-} satisfies Config
diff --git a/examples/streaming/pages/_error/+Page.tsx b/examples/streaming/pages/_error/+Page.tsx
deleted file mode 100644
index 2fa8b1cc..00000000
--- a/examples/streaming/pages/_error/+Page.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-export default Page
-
-import React from 'react'
-import { usePageContext } from 'vike-react/usePageContext'
-
-function Page() {
- const { is404 } = usePageContext()
- if (is404) {
- return (
- <>
- 404 Page Not Found
- This page could not be found.
- >
- )
- } else {
- return (
- <>
- 500 Internal Server Error
- Something went wrong.
- >
- )
- }
-}
diff --git a/examples/streaming/readme.md b/examples/streaming/readme.md
deleted file mode 100644
index 1adc30fc..00000000
--- a/examples/streaming/readme.md
+++ /dev/null
@@ -1,8 +0,0 @@
-Example of streaming the page's HTML.
-
-```bash
-git clone git@github.com:vikejs/vike-react
-cd vike-react/examples/streaming/
-npm install
-npm run dev
-```
diff --git a/examples/streaming/tsconfig.json b/examples/streaming/tsconfig.json
deleted file mode 100644
index e0bb64ac..00000000
--- a/examples/streaming/tsconfig.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "compilerOptions": {
- "strict": true,
- "module": "ES2020",
- "moduleResolution": "Node",
- "target": "ES2020",
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
- "types": ["vite/client"],
- "jsx": "react",
- "skipLibCheck": true,
- "esModuleInterop": true
- }
-}
diff --git a/examples/streaming/vite.config.ts b/examples/streaming/vite.config.ts
deleted file mode 100644
index e8b93550..00000000
--- a/examples/streaming/vite.config.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import react from '@vitejs/plugin-react'
-import vike from 'vike/plugin'
-import { UserConfig } from 'vite'
-
-export default {
- plugins: [react(), vike()]
-} satisfies UserConfig
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ab2e7085..9c6e98b4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -48,6 +48,9 @@ importers:
react-dom:
specifier: 18.2.0
version: 18.2.0(react@18.2.0)
+ react-streaming:
+ specifier: ^0.3.22
+ version: 0.3.22(react-dom@18.2.0)(react@18.2.0)
typescript:
specifier: ^5.3.3
version: 5.3.3
@@ -127,39 +130,6 @@ importers:
specifier: ^5.1.1
version: 5.1.1(@types/node@20.11.17)
- examples/streaming:
- dependencies:
- '@types/react':
- specifier: ^18.2.55
- version: 18.2.55
- '@types/react-dom':
- specifier: ^18.2.19
- version: 18.2.19
- '@vitejs/plugin-react':
- specifier: ^4.2.1
- version: 4.2.1(vite@5.1.1)
- react:
- specifier: 18.2.0
- version: 18.2.0
- react-dom:
- specifier: 18.2.0
- version: 18.2.0(react@18.2.0)
- react-streaming:
- specifier: ^0.3.22
- version: 0.3.22(react-dom@18.2.0)(react@18.2.0)
- typescript:
- specifier: ^5.3.3
- version: 5.3.3
- vike:
- specifier: ^0.4.168
- version: 0.4.168(react-streaming@0.3.22)(vite@5.1.1)
- vike-react:
- specifier: link:../../packages/vike-react
- version: link:../../packages/vike-react
- vite:
- specifier: ^5.1.1
- version: 5.1.1(@types/node@20.11.17)
-
packages/vike-react:
dependencies:
react-streaming: