Skip to content

Commit 97799f1

Browse files
add new code to _app.tsx
1 parent e55981f commit 97799f1

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@types/google.maps": "^3.58.1",
6161
"@types/jsonwebtoken": "^8.5.8",
6262
"@types/marked": "^4.0.3",
63+
"@types/next-auth": "^3.15.0",
6364
"@types/node": "^18.0.0",
6465
"@types/react": "18.0.0",
6566
"@types/react-dom": "18.0.0",

src/pages/_app.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ElementType, useEffect } from "react";
22
import { useRouter } from "next/router";
3-
import type { AppProps } from "next/app";
43
import { SessionProvider } from "next-auth/react"; // Import SessionProvider
4+
import type { Session } from "next-auth"; // Import Session type
5+
import type { AppProps, NextPage } from "next"; // Import NextPage
56
import SEO from "@components/seo/deafult-seo";
67
import FallbackLayout from "@layout/fallback";
78
import "@assets/css/font-awesome-pro.min.css";
@@ -14,11 +15,14 @@ import "@assets/css/globals.css";
1415
import { UIProvider } from "../contexts/ui-context";
1516
import { UserProvider } from "../contexts/user-context";
1617

17-
interface CustomAppProps extends Omit<AppProps, "Component"> {
18-
Component: AppProps["Component"] & { Layout: ElementType };
18+
// Extend AppProps with support for a Layout property
19+
interface CustomAppProps extends AppProps {
20+
Component: NextPage & {
21+
Layout?: ElementType; // Optional Layout property
22+
};
1923
pageProps: {
24+
session?: Session | null; // Explicitly type session
2025
[key: string]: unknown;
21-
session?: unknown; // Add session type for NextAuth
2226
};
2327
}
2428

@@ -38,7 +42,7 @@ const MyApp = ({ Component, pageProps }: CustomAppProps) => {
3842
});
3943

4044
return (
41-
<SessionProvider session={pageProps.session}> {/* Wrap everything in SessionProvider */}
45+
<SessionProvider session={pageProps.session as Session | null}>
4246
<UIProvider>
4347
<UserProvider>
4448
<Layout {...layoutProps}>

tsconfig.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
"@widgets/*": ["components/widgets/*"],
3434
"@fonts/*": ["public/fonts/*"]
3535
},
36-
"types": ["google.maps"] // Add this line
36+
"types": ["google.maps", "next-auth"] // Add "next-auth" here
3737
},
3838
"include": [
39-
"next-env.d.ts",
40-
"next.config.js",
41-
"src/**/*.ts",
42-
"src/**/*.tsx",
43-
"tailwind.config.js",
44-
"postcss.config.js",
39+
"next-env.d.ts",
40+
"next.config.js",
41+
"src/**/*.ts",
42+
"src/**/*.tsx",
43+
"tailwind.config.js",
44+
"postcss.config.js",
4545
"next-sitemap.config.js"
4646
],
4747
"exclude": ["node_modules"]

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,13 @@
19491949
"resolved" "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz"
19501950
"version" "5.1.2"
19511951

1952+
"@types/next-auth@^3.15.0":
1953+
"integrity" "sha512-ZVfejlu81YiIRX1m0iKAfvZ3nK7K9EyZWhNARNKsFop8kNAgEvMnlKpTpwN59xkK2OhyWLagPuiDAVBYSO9jSA=="
1954+
"resolved" "https://registry.npmjs.org/@types/next-auth/-/next-auth-3.15.0.tgz"
1955+
"version" "3.15.0"
1956+
dependencies:
1957+
"next-auth" "*"
1958+
19521959
"@types/node-fetch@^2.6.4":
19531960
"integrity" "sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg=="
19541961
"resolved" "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.4.tgz"
@@ -4955,7 +4962,7 @@
49554962
"resolved" "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz"
49564963
"version" "0.6.3"
49574964

4958-
"next-auth@^4.24.10":
4965+
"next-auth@*", "next-auth@^4.24.10":
49594966
"integrity" "sha512-8NGqiRO1GXBcVfV8tbbGcUgQkAGsX4GRzzXXea4lDikAsJtD5KiEY34bfhUOjHLvr6rT6afpcxw2H8EZqOV6aQ=="
49604967
"resolved" "https://registry.npmjs.org/next-auth/-/next-auth-4.24.10.tgz"
49614968
"version" "4.24.10"

0 commit comments

Comments
 (0)