Skip to content

Commit

Permalink
feat: ✨ add a function to redirect if user is not logged yet to login…
Browse files Browse the repository at this point in the history
… page
  • Loading branch information
neopromic committed Nov 6, 2024
1 parent 9ef4bfb commit 8931f21
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
const Home = () => {
return (
import { auth } from "@clerk/nextjs/server";
import { redirect } from "next/navigation";

const Home = async () => {
const { userId } = await auth();

if (!userId) {
redirect("/login");
}

return (
<div>
<h1>Home</h1>
</div>
);
}
export default Home;
};

export default Home;

0 comments on commit 8931f21

Please sign in to comment.