Skip to content

Commit 8b6602d

Browse files
authored
Merge pull request #14 from react18-tools/fix-next-pages-router
Fix next pages router
2 parents 1854472 + c5fbc77 commit 8b6602d

File tree

22 files changed

+594
-48
lines changed

22 files changed

+594
-48
lines changed

.changeset/early-insects-brake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nextjs-darkmode": patch
3+
---
4+
5+
Fix Next.js pages router by upgrading useRGS

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ $ yarn add nextjs-darkmode
7676

7777
### Import Styles
7878

79+
> PLease make sure you set `"moduleResolution"` to `"Bundler"`, `"Node16"` or `"NodeNext"` in your tsconfig file for export field in package.json to work properly. (Ref)[https://stackoverflow.com/a/74462490/23175171]
80+
81+
> You may need to import styles from `nextjs-darkmode/dist/index.css` depending on your bundler configuration.
82+
7983
Import styles globally or within layout component.
8084

8185
```css

examples/nextjs-pages/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import("eslint").Linter.Config} */
2+
module.exports = {
3+
extends: ["@repo/eslint-config/next.js"],
4+
parser: "@typescript-eslint/parser",
5+
parserOptions: {
6+
project: true,
7+
},
8+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"telemetry": {
3+
"notifiedAt": "1715050199607",
4+
"enabled": false
5+
}
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
reactStrictMode: true,
3+
};

examples/nextjs-pages/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@example/pages",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"build": "next build",
7+
"clean": "rm -rf .next",
8+
"dev": "next dev",
9+
"lint": "next lint",
10+
"typecheck": "tsc --noEmit",
11+
"start": "next start"
12+
},
13+
"dependencies": {
14+
"next": "14.2.4",
15+
"nextjs-darkmode": "workspace:*",
16+
"@repo/shared": "workspace:*",
17+
"react": "^18",
18+
"react-dom": "^18"
19+
},
20+
"devDependencies": {
21+
"@next/eslint-plugin-next": "^14.2.4",
22+
"@repo/eslint-config": "workspace:*",
23+
"@repo/typescript-config": "workspace:*",
24+
"@types/node": "^20",
25+
"@types/react": "^18",
26+
"@types/react-dom": "^18",
27+
"typescript": "^5.4.5"
28+
}
29+
}
25.3 KB
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import "../styles/globals.css";
2+
import type { AppProps } from "next/app";
3+
import { Core } from "nextjs-darkmode";
4+
import { Layout } from "@repo/shared/dist/server";
5+
import { Header } from "@repo/shared";
6+
import { Inter } from "next/font/google";
7+
8+
const inter = Inter({ subsets: ["latin"] });
9+
10+
/** Default app */
11+
export default function App({ Component, pageProps }: AppProps) {
12+
return (
13+
<>
14+
<Core t="all .5s" />
15+
<Layout className={inter.className}>
16+
<Header />
17+
<Component {...pageProps} />;
18+
</Layout>
19+
</>
20+
);
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Html, Head, Main, NextScript } from "next/document";
2+
3+
/** Custom document */
4+
export default function Document() {
5+
return (
6+
<Html lang="en">
7+
<Head />
8+
<body>
9+
<Main />
10+
<NextScript />
11+
</body>
12+
</Html>
13+
);
14+
}

0 commit comments

Comments
 (0)