Add SuperTokens authentication integration
- Install supertokens-auth-react, supertokens-node, supertokens-web-js - Create frontend and backend SuperTokens configuration - Add API route handler for auth endpoints - Add SuperTokensProvider wrapper in root layout - Create new auth component with SuperTokens UI - Configure Google and GitHub OAuth providers - Ready for SuperTokens core deployment Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
49
lib/supertokens/backendConfig.ts
Normal file
49
lib/supertokens/backendConfig.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import ThirdPartyEmailPasswordNode from "supertokens-node/recipe/thirdpartyemailpassword";
|
||||
import SessionNode from "supertokens-node/recipe/session";
|
||||
import { TypeInput } from "supertokens-node/types";
|
||||
import { AppInfoUserInput } from "supertokens-node/types";
|
||||
|
||||
const appInfo: AppInfoUserInput = {
|
||||
appName: "Vib'n",
|
||||
apiDomain: process.env.NEXT_PUBLIC_APP_URL || "https://app.vibnai.com",
|
||||
websiteDomain: process.env.NEXT_PUBLIC_APP_URL || "https://app.vibnai.com",
|
||||
apiBasePath: "/api/auth",
|
||||
websiteBasePath: "/auth",
|
||||
};
|
||||
|
||||
export const backendConfig = (): TypeInput => {
|
||||
return {
|
||||
framework: "custom",
|
||||
supertokens: {
|
||||
connectionURI: process.env.SUPERTOKENS_CONNECTION_URI || "https://auth.vibnai.com",
|
||||
apiKey: process.env.SUPERTOKENS_API_KEY,
|
||||
},
|
||||
appInfo,
|
||||
recipeList: [
|
||||
ThirdPartyEmailPasswordNode.init({
|
||||
providers: [
|
||||
{
|
||||
config: {
|
||||
thirdPartyId: "google",
|
||||
clients: [{
|
||||
clientId: process.env.GOOGLE_CLIENT_ID || "",
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
|
||||
}],
|
||||
},
|
||||
},
|
||||
{
|
||||
config: {
|
||||
thirdPartyId: "github",
|
||||
clients: [{
|
||||
clientId: process.env.GITHUB_CLIENT_ID || "",
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET || "",
|
||||
}],
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
SessionNode.init(),
|
||||
],
|
||||
isInServerlessEnv: true,
|
||||
};
|
||||
};
|
||||
30
lib/supertokens/frontendConfig.ts
Normal file
30
lib/supertokens/frontendConfig.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import ThirdPartyEmailPassword, {
|
||||
Google,
|
||||
Github,
|
||||
} from "supertokens-auth-react/recipe/thirdpartyemailpassword";
|
||||
import Session from "supertokens-auth-react/recipe/session";
|
||||
|
||||
export const frontendConfig = () => {
|
||||
const appUrl = process.env.NEXT_PUBLIC_APP_URL || "https://app.vibnai.com";
|
||||
|
||||
return {
|
||||
appInfo: {
|
||||
appName: "Vib'n",
|
||||
apiDomain: appUrl,
|
||||
websiteDomain: appUrl,
|
||||
apiBasePath: "/api/auth",
|
||||
websiteBasePath: "/auth",
|
||||
},
|
||||
recipeList: [
|
||||
ThirdPartyEmailPassword.init({
|
||||
signInAndUpFeature: {
|
||||
providers: [
|
||||
Google.init(),
|
||||
Github.init(),
|
||||
],
|
||||
},
|
||||
}),
|
||||
Session.init(),
|
||||
],
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user