diff --git a/src/app/providers.tsx b/src/app/providers.tsx
index 6803006..7601519 100644
--- a/src/app/providers.tsx
+++ b/src/app/providers.tsx
@@ -4,6 +4,7 @@ import type { ReactNode } from "react";
import { SessionProvider } from "next-auth/react";
import { AccountProvider } from "@/components/AccountContext";
import { ThemeProvider } from "@/components/ThemeContext";
+import BackToTopButton from "@/components/BackToTopButton";
export default function Providers({ children }: { children: ReactNode }) {
return (
@@ -11,6 +12,7 @@ export default function Providers({ children }: { children: ReactNode }) {
{children}
+
diff --git a/src/components/BackToTopButton.tsx b/src/components/BackToTopButton.tsx
new file mode 100644
index 0000000..b7fb4be
--- /dev/null
+++ b/src/components/BackToTopButton.tsx
@@ -0,0 +1,63 @@
+"use client";
+
+import { useEffect, useState } from "react";
+
+export default function BackToTopButton() {
+ const [isVisible, setIsVisible] = useState(false);
+
+ // Show button when page is scrolled down
+ const toggleVisibility = () => {
+ if (typeof window !== "undefined") {
+ setIsVisible(window.scrollY > 300);
+ }
+ };
+
+ // Smooth scroll to top
+ const scrollToTop = () => {
+ if (typeof window !== "undefined") {
+ window.scrollTo({
+ top: 0,
+ behavior: "smooth",
+ });
+ }
+ };
+
+ useEffect(() => {
+ if (typeof window !== "undefined") {
+ window.addEventListener("scroll", toggleVisibility);
+ return () => {
+ window.removeEventListener("scroll", toggleVisibility);
+ };
+ }
+ }, []);
+
+ return (
+ <>
+ {isVisible && (
+
+ )}
+ >
+ );
+}