aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/PrivateRoute.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/PrivateRoute.jsx')
-rw-r--r--src/utils/PrivateRoute.jsx9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/PrivateRoute.jsx b/src/utils/PrivateRoute.jsx
new file mode 100644
index 0000000..b57bcf5
--- /dev/null
+++ b/src/utils/PrivateRoute.jsx
@@ -0,0 +1,9 @@
+import React from 'react';
+import { Navigate } from 'react-router-dom';
+
+const PrivateRoute = ({ children }) => {
+ const token = localStorage.getItem('token');
+ return token ? children : <Navigate to="/" />;
+};
+
+export default PrivateRoute;