-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add example with Next.js (with app router)
- Loading branch information
1 parent
b0568b2
commit 61f4449
Showing
36 changed files
with
74 additions
and
127 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
File renamed without changes.
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
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
...ages-router-custom-server/next.config.mjs → examples/nextjs-app-router/next.config.mjs
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,6 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
}; | ||
const nextConfig = {}; | ||
|
||
export default nextConfig; |
3 changes: 2 additions & 1 deletion
3
...extjs-pages-router-api-route/package.json → examples/nextjs-app-router/package.json
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
File renamed without changes
File renamed without changes
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
File renamed without changes.
File renamed without changes.
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 { Inter } from "next/font/google"; | ||
import "./globals.css"; | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
|
||
export const metadata = { | ||
title: "Create Next App", | ||
description: "Generated by create next app", | ||
}; | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}>{children}</body> | ||
</html> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use client"; | ||
|
||
import { io } from "socket.io-client"; | ||
|
||
export const socket = io(); |
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
examples/nextjs-pages-router-api-route/src/pages/api/socket.io.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
examples/nextjs-pages-router-custom-server/src/pages/_document.js
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
examples/nextjs-pages-router-custom-server/src/pages/api/hello.js
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
# next.js | ||
/.next/ | ||
/out/ | ||
/src/.next/ | ||
|
||
# production | ||
/build | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...s-pages-router-custom-server/package.json → examples/nextjs-pages-router/package.json
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
File renamed without changes.
File renamed without changes
File renamed without changes
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,29 @@ | ||
import { createServer } from "http"; | ||
import next from "next"; | ||
import { Server } from "socket.io"; | ||
|
||
const dev = process.env.NODE_ENV !== "production"; | ||
const hostname = "localhost"; | ||
const port = 3000; | ||
// when using middleware `hostname` and `port` must be provided below | ||
const app = next({ dev, hostname, port }); | ||
const handler = app.getRequestHandler(); | ||
|
||
app.prepare().then(() => { | ||
const httpServer = createServer(handler); | ||
|
||
const io = new Server(httpServer); | ||
|
||
io.on("connection", (socket) => { | ||
// ... | ||
}); | ||
|
||
httpServer | ||
.once("error", (err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}) | ||
.listen(port, () => { | ||
console.log(`> Ready on http://${hostname}:${port}`); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.