Unverified Commit 4fbf3d37 authored by Rishabh Poddar's avatar Rishabh Poddar Committed by GitHub

Update to with-supertokens example (#66320)

Updates to using latest supertokens' SDK versions.
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent 3d2494a3
...@@ -60,7 +60,8 @@ export async function HomePage() { ...@@ -60,7 +60,8 @@ export async function HomePage() {
if (hasInvalidClaims) { if (hasInvalidClaims) {
return <SessionAuthForNextJS />; return <SessionAuthForNextJS />;
} else { } else {
return <TryRefreshComponent />; // To learn about why the 'key' attribute is required refer to: https://github.com/supertokens/supertokens-node/issues/826#issuecomment-2092144048
return <TryRefreshComponent key={Date.now()} />;
} }
} }
......
import ThirdPartyEmailPasswordNode from "supertokens-node/recipe/thirdpartyemailpassword"; import ThirdPartyNode from "supertokens-node/recipe/thirdparty";
import EmailPasswordNode from "supertokens-node/recipe/emailpassword";
import SessionNode from "supertokens-node/recipe/session"; import SessionNode from "supertokens-node/recipe/session";
import Dashboard from "supertokens-node/recipe/dashboard"; import Dashboard from "supertokens-node/recipe/dashboard";
import UserRoles from "supertokens-node/recipe/userroles"; import UserRoles from "supertokens-node/recipe/userroles";
...@@ -16,7 +17,9 @@ export let backendConfig = (): TypeInput => { ...@@ -16,7 +17,9 @@ export let backendConfig = (): TypeInput => {
// recipeList contains all the modules that you want to // recipeList contains all the modules that you want to
// use from SuperTokens. See the full list here: https://supertokens.com/docs/guides // use from SuperTokens. See the full list here: https://supertokens.com/docs/guides
recipeList: [ recipeList: [
ThirdPartyEmailPasswordNode.init({ EmailPasswordNode.init(),
ThirdPartyNode.init({
signInAndUpFeature: {
providers: [ providers: [
// We have provided you with development keys which you can use for testing. // We have provided you with development keys which you can use for testing.
// IMPORTANT: Please replace them with your own OAuth keys for production use. // IMPORTANT: Please replace them with your own OAuth keys for production use.
...@@ -72,6 +75,7 @@ export let backendConfig = (): TypeInput => { ...@@ -72,6 +75,7 @@ export let backendConfig = (): TypeInput => {
}, },
}, },
], ],
},
}), }),
SessionNode.init(), SessionNode.init(),
Dashboard.init(), Dashboard.init(),
......
import ThirdPartyEmailPasswordReact from "supertokens-auth-react/recipe/thirdpartyemailpassword"; import ThirdPartyReact from "supertokens-auth-react/recipe/thirdparty";
import EmailPasswordReact from "supertokens-auth-react/recipe/emailpassword";
import Session from "supertokens-auth-react/recipe/session"; import Session from "supertokens-auth-react/recipe/session";
import { appInfo } from "./appInfo"; import { appInfo } from "./appInfo";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { SuperTokensConfig } from "supertokens-auth-react/lib/build/types"; import { SuperTokensConfig } from "supertokens-auth-react/lib/build/types";
import { ThirdPartyEmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/thirdpartyemailpassword/prebuiltui"; import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpassword/prebuiltui";
const routerInfo: { router?: ReturnType<typeof useRouter>; pathName?: string } = const routerInfo: { router?: ReturnType<typeof useRouter>; pathName?: string } =
{}; {};
...@@ -20,12 +22,13 @@ export const frontendConfig = (): SuperTokensConfig => { ...@@ -20,12 +22,13 @@ export const frontendConfig = (): SuperTokensConfig => {
return { return {
appInfo, appInfo,
recipeList: [ recipeList: [
ThirdPartyEmailPasswordReact.init({ EmailPasswordReact.init(),
ThirdPartyReact.init({
signInAndUpFeature: { signInAndUpFeature: {
providers: [ providers: [
ThirdPartyEmailPasswordReact.Google.init(), ThirdPartyReact.Google.init(),
ThirdPartyEmailPasswordReact.Github.init(), ThirdPartyReact.Github.init(),
ThirdPartyEmailPasswordReact.Apple.init(), ThirdPartyReact.Apple.init(),
], ],
}, },
}), }),
...@@ -49,4 +52,4 @@ export const recipeDetails = { ...@@ -49,4 +52,4 @@ export const recipeDetails = {
docsLink: "https://supertokens.com/docs/thirdpartyemailpassword/introduction", docsLink: "https://supertokens.com/docs/thirdpartyemailpassword/introduction",
}; };
export const PreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI]; export const PreBuiltUIList = [ThirdPartyPreBuiltUI, EmailPasswordPreBuiltUI];
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
"@types/react-dom": "^18", "@types/react-dom": "^18",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "13.5.4", "eslint-config-next": "13.5.4",
"i": "^0.3.7",
"npm": "^10.2.0",
"typescript": "^5" "typescript": "^5"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment