Skip to content

Commit

Permalink
update vercel example
Browse files Browse the repository at this point in the history
  • Loading branch information
nitedani committed Aug 6, 2024
1 parent 066064f commit 8c5cfde
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 32 deletions.
4 changes: 3 additions & 1 deletion examples/express-react-vercel/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import app from '../dist/server/index.mjs'

// Web request handlers support streaming by default on Vercel
import { connectToWeb } from 'vike-node'
export const GET = connectToWeb(app)
const handler = connectToWeb(app)
export const GET = handler
export const POST = handler
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ function Layout({ children }) {
<PageLayout>
<Sidebar>
<a className="navitem" href="/">
Home
Pre-rendered
</a>
<a className="navitem" href="/about">
About
<a className="navitem" href="/dynamic">
Dynamic
</a>
</Sidebar>
<Content>{children}</Content>
Expand Down
6 changes: 2 additions & 4 deletions examples/express-react-vercel/pages/+config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
export { config }

import vikeReact from 'vike-react/config'
import { Layout } from './Layout'

const config = {
// https://vike.dev/Layout
Layout: Layout,
// https://vike.dev/extends
extends: vikeReact
extends: vikeReact,
prerender: false
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import React from 'react'
function Page() {
return (
<>
<h1>About</h1>
<p>Example of using Vike.</p>
<h1>Dynamic</h1>
This page is rendered to HTML at {new Date().toLocaleString('en')}.
</>
)
}
11 changes: 2 additions & 9 deletions examples/express-react-vercel/pages/index/+Page.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
export default Page

import React from 'react'
import { Counter } from './Counter'

function Page() {
return (
<>
<h1>Welcome</h1>
This page is:
<ul>
<li>Rendered to HTML.</li>
<li>
Interactive. <Counter />
</li>
</ul>
<h1>Pre-rendered</h1>
This page is pre-rendered to HTML at {new Date().toLocaleString('en')}.
</>
)
}
3 changes: 3 additions & 0 deletions examples/express-react-vercel/pages/index/+config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
prerender: true
}
12 changes: 0 additions & 12 deletions examples/express-react-vercel/pages/index/Counter.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion examples/express-react-vercel/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import vike from 'vike/plugin'
import vikeNode from 'vike-node/plugin'

export default {
plugins: [react(), vike(), vikeNode('server/index.js')]
plugins: [react(), vike({ prerender: true }), vikeNode('server/index.js')]
}

0 comments on commit 8c5cfde

Please sign in to comment.