Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
4965387a
Commit
4965387a
authored
Jan 31, 2018
by
Logan McAnsh
Committed by
Tim Neutkens
Jan 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Polka server example (#3588)
* add Polka server example * Update package.json * Fix linting
parent
99272808
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
0 deletions
+59
-0
package.json
examples/custom-server-polka/package.json
+15
-0
a.js
examples/custom-server-polka/pages/a.js
+3
-0
b.js
examples/custom-server-polka/pages/b.js
+3
-0
index.js
examples/custom-server-polka/pages/index.js
+17
-0
server.js
examples/custom-server-polka/server.js
+21
-0
No files found.
examples/custom-server-polka/package.json
0 → 100644
View file @
4965387a
{
"name"
:
"custom-server-polka"
,
"version"
:
"1.0.0"
,
"scripts"
:
{
"dev"
:
"node server.js"
,
"build"
:
"next build"
,
"start"
:
"NODE_ENV=production node server.js"
},
"dependencies"
:
{
"next"
:
"latest"
,
"polka"
:
"0.2.3"
,
"react"
:
"16.2.0"
,
"react-dom"
:
"16.2.0"
}
}
examples/custom-server-polka/pages/a.js
0 → 100644
View file @
4965387a
import
React
from
'react'
export
default
()
=>
<
div
>
a
<
/div
>
examples/custom-server-polka/pages/b.js
0 → 100644
View file @
4965387a
import
React
from
'react'
export
default
()
=>
<
div
>
b
<
/div
>
examples/custom-server-polka/pages/index.js
0 → 100644
View file @
4965387a
import
React
from
'react'
import
Link
from
'next/link'
export
default
()
=>
(
<
ul
>
<
li
>
<
Link
href
=
'/b'
as
=
'/a'
>
<
a
>
a
<
/a
>
<
/Link
>
<
/li
>
<
li
>
<
Link
href
=
'/a'
as
=
'/b'
>
<
a
>
b
<
/a
>
<
/Link
>
<
/li
>
<
/ul
>
)
examples/custom-server-polka/server.js
0 → 100644
View file @
4965387a
const
polka
=
require
(
'polka'
)
const
next
=
require
(
'next'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'production'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
app
.
prepare
().
then
(()
=>
{
const
server
=
polka
()
server
.
get
(
'/a'
,
(
req
,
res
)
=>
app
.
render
(
req
,
res
,
'/b'
,
req
.
query
))
server
.
get
(
'/b'
,
(
req
,
res
)
=>
app
.
render
(
req
,
res
,
'/a'
,
req
.
query
))
server
.
get
(
'*'
,
(
req
,
res
)
=>
handle
(
req
,
res
))
server
.
listen
(
port
)
.
then
(()
=>
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
))
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment