-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,163 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/dist/ | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"prod": "cross-env NODE_ENV=production node dist/server/index.mjs", | ||
"preview": "vite build && wrangler pages dev", | ||
"deploy": "vite build && wrangler pages deploy" | ||
}, | ||
"dependencies": { | ||
"@hono/node-server": "^1.12.0", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"cross-env": "^7.0.3", | ||
"hono": "^4.5.5", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"vike": "^0.4.181", | ||
"vike-node": "0.1.9-commit-022aa1c", | ||
"vike-react": "^0.4.18", | ||
"vite": "^5.3.5" | ||
}, | ||
"type": "module", | ||
"devDependencies": { | ||
"vike-cloudflare": "^0.0.5", | ||
"wrangler": "^3.70.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
export { Layout } | ||
|
||
import React from 'react' | ||
import './Layout.css' | ||
|
||
function Layout({ children }) { | ||
return ( | ||
<PageLayout> | ||
<Sidebar> | ||
<a className="navitem" href="/"> | ||
Pre-rendered | ||
</a> | ||
<a className="navitem" href="/dynamic"> | ||
Dynamic | ||
</a> | ||
<a className="navitem" href="/static"> | ||
Static | ||
</a> | ||
</Sidebar> | ||
<Content>{children}</Content> | ||
</PageLayout> | ||
) | ||
} | ||
|
||
function PageLayout({ children }) { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
maxWidth: 900, | ||
margin: 'auto' | ||
}} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
function Sidebar({ children }) { | ||
return ( | ||
<div | ||
style={{ | ||
padding: 20, | ||
paddingTop: 42, | ||
flexShrink: 0, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
lineHeight: '1.8em' | ||
}} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
function Content({ children }) { | ||
return ( | ||
<div | ||
style={{ | ||
padding: 20, | ||
paddingBottom: 50, | ||
borderLeft: '2px solid #eee', | ||
minHeight: '100vh' | ||
}} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export { config } | ||
|
||
import vikeReact from 'vike-react/config' | ||
|
||
const config = { | ||
// https://vike.dev/extends | ||
extends: vikeReact, | ||
prerender: false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
body { | ||
margin: 0; | ||
font-family: sans-serif; | ||
} | ||
* { | ||
box-sizing: border-box; | ||
} | ||
a { | ||
text-decoration: none; | ||
} | ||
|
||
.navitem { | ||
padding: 3px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export default Page | ||
|
||
import React, { useState } from 'react' | ||
|
||
function Page() { | ||
return ( | ||
<> | ||
<h1>Welcome</h1> | ||
This page is: | ||
<ul> | ||
<li>Dynamic</li> | ||
<li>No static html generated</li> | ||
<li>Interactive</li> | ||
</ul> | ||
<Counter /> | ||
</> | ||
) | ||
} | ||
|
||
function Counter() { | ||
const [count, setCount] = useState(0) | ||
return ( | ||
<button type="button" onClick={() => setCount((count) => count + 1)}> | ||
Counter {count} | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export default Page | ||
|
||
import React, { useState } from 'react' | ||
|
||
function Page() { | ||
return ( | ||
<> | ||
<h1>Welcome</h1> | ||
This page is: | ||
<ul> | ||
<li>Pre-rendered</li> | ||
<li>Static html generated</li> | ||
<li>Interactive</li> | ||
</ul> | ||
<Counter /> | ||
</> | ||
) | ||
} | ||
|
||
function Counter() { | ||
const [count, setCount] = useState(0) | ||
return ( | ||
<button type="button" onClick={() => setCount((count) => count + 1)}> | ||
Counter {count} | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
prerender: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export default Page | ||
|
||
import React, { useState } from 'react' | ||
|
||
function Page() { | ||
return ( | ||
<> | ||
<h1>Welcome</h1> | ||
This page is: | ||
<ul> | ||
<li>Pre-rendered</li> | ||
<li>Static html generated</li> | ||
<li>Not interactive (no javascript is downloaded for this page)</li> | ||
</ul> | ||
<Counter /> | ||
</> | ||
) | ||
} | ||
|
||
function Counter() { | ||
const [count, setCount] = useState(0) | ||
return ( | ||
<button type="button" onClick={() => setCount((count) => count + 1)}> | ||
Counter {count} | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// https://vike.dev/render-modes#html-only | ||
|
||
export default { | ||
prerender: true, | ||
meta: { | ||
Page: { | ||
env: { server: true, client: false } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Minimal example of using `vike-node` and `vike-react`. | ||
|
||
```bash | ||
git clone [email protected]:vikejs/vike-node | ||
cd vike-node/examples/hono-react-vercel-edge/ | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
## One-Click Deploy | ||
|
||
Deploy the example using [Vercel](https://vercel.com): | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vikejs/vike-node/tree/vercel-edge/examples/hono-react-vercel-edge&project-name=hono-react&repository-name=hono-react) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Hono } from 'hono' | ||
import vike from 'vike-node/hono' | ||
|
||
const app = new Hono() | ||
app.use(vike()) | ||
export default app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { serve } from '@hono/node-server' | ||
import app from './hono-entry.js' | ||
|
||
startServer() | ||
|
||
function startServer() { | ||
const port = process.env.PORT || 3000 | ||
serve( | ||
{ | ||
fetch: app.fetch, | ||
port: +port, | ||
// Needed for Bun | ||
overrideGlobalObjects: false | ||
}, | ||
() => console.log(`Server running at http://localhost:${port}`) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import react from '@vitejs/plugin-react' | ||
import vike from 'vike/plugin' | ||
import vikeNode from 'vike-node/plugin' | ||
import { pages } from 'vike-cloudflare' | ||
|
||
export default { | ||
plugins: [ | ||
react(), | ||
vike({ prerender: true }), | ||
vikeNode({ entry: 'server/node-entry.js', external: ['vike-node/__handler'] }), | ||
pages({ | ||
server: { | ||
kind: 'hono', | ||
entry: 'server/hono-entry.js' | ||
} | ||
}) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name = "vike-cloudflare-hono-demo" | ||
compatibility_date = "2024-06-24" | ||
pages_build_output_dir = "./dist/cloudflare" | ||
compatibility_flags = [ "nodejs_compat" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/node_modules/ | ||
/dist/ | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.