+ handleLogin("kakao")}>
카카오톡으로 로그인
diff --git a/src/pages/Login/index.jsx b/src/pages/Login/index.jsx
new file mode 100644
index 0000000..329727b
--- /dev/null
+++ b/src/pages/Login/index.jsx
@@ -0,0 +1,37 @@
+import React, { useEffect } from "react";
+import axios from "axios";
+import { useNavigate, useLocation } from "react-router-dom";
+import { useSetRecoilState } from "recoil";
+import { loginState } from "../../store/atoms";
+
+const Login = () => {
+ const navigate = useNavigate();
+ const location = useLocation();
+ const setLoginState = useSetRecoilState(loginState);
+
+ useEffect(() => {
+ // Parse the URL to get the JWT
+ const jwt = new URL(window.location.href).searchParams.get("jwt");
+
+ if (jwt) {
+ // If JWT exists, set it in the headers
+ axios.defaults.headers.common["Authorization"] = `Bearer ${jwt}`;
+
+ // Set login state to true
+ setLoginState(true);
+
+ // Redirect to the home screen
+ navigate("/");
+ console.log("로그인!");
+ }
+ }, [navigate, location.search, setLoginState]);
+
+ return (
+
+ {/* You can add a loading spinner or other UI elements here */}
+ Logging in...
+
+ );
+};
+
+export default Login;
diff --git a/src/pages/Login/styled.js b/src/pages/Login/styled.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/store/atoms.js b/src/store/atoms.js
index 0071dbe..f9d3a64 100644
--- a/src/store/atoms.js
+++ b/src/store/atoms.js
@@ -1,4 +1,5 @@
import { atom } from "recoil";
+import { recoilPersist } from "recoil-persist";
export const testState = atom({
key: "testState",
@@ -12,3 +13,14 @@ export const testState = atom({
O: 0,
},
});
+
+const { persistAtom } = recoilPersist({
+ key: "recoil-persist",
+ storage: sessionStorage,
+});
+
+export const loginState = atom({
+ key: "loginState",
+ default: false,
+ effects_UNSTABLE: [persistAtom],
+});