SurfSense/surfsense_web
DESKTOP-RTLN3BA\$punk 66c92129b1 fix docs
2025-05-08 19:53:15 -07:00
..
.vscode feat: monorepo 2025-04-07 23:47:06 -07:00
app fix: Added API_BASE param for LiteLLM. 2025-05-08 19:31:47 -07:00
components feat: Added Podcast Feature and its actually fast. 2025-05-05 23:18:12 -07:00
content/docs fix docs 2025-05-08 19:53:15 -07:00
hooks feat: Added LinkUP Search Engine Connector 2025-04-27 15:53:33 -07:00
lib feat: Added LinkUP Search Engine Connector 2025-04-27 15:53:33 -07:00
public chore: docs 2025-04-23 15:22:43 -07:00
.cursorrules feat: monorepo 2025-04-07 23:47:06 -07:00
.dockerignore feat: monorepo 2025-04-07 23:47:06 -07:00
.env.example chore: updated .gitignore files and added forgotten .env.example to frontend. 2025-04-10 23:43:47 -07:00
.gitignore updated .gitignore 2025-04-22 02:40:45 -07:00
components.json feat: monorepo 2025-04-07 23:47:06 -07:00
Dockerfile fix: update Dockerfile to handle fumadocs-mdx postinstall error by copying config and content before installation 2025-04-24 18:23:11 -07:00
eslint.config.mjs feat: monorepo 2025-04-07 23:47:06 -07:00
LICENSE feat: monorepo 2025-04-07 23:47:06 -07:00
mdx-components.tsx feat: Added FumaDocs 2025-04-22 02:24:13 -07:00
next.config.ts feat: Added FumaDocs 2025-04-22 02:24:13 -07:00
package-lock.json feat: monorepo 2025-04-07 23:47:06 -07:00
package.json feat: Added Podcast Feature and its actually fast. 2025-05-05 23:18:12 -07:00
pnpm-lock.yaml feat: Added Podcast Feature and its actually fast. 2025-05-05 23:18:12 -07:00
postcss.config.mjs feat: monorepo 2025-04-07 23:47:06 -07:00
README.md feat: monorepo 2025-04-07 23:47:06 -07:00
source.config.ts feat: Added FumaDocs 2025-04-22 02:24:13 -07:00
tailwind.config.js feat: monorepo 2025-04-07 23:47:06 -07:00
tsconfig.json feat: Added FumaDocs 2025-04-22 02:24:13 -07:00

Next.js Token Handler Component

This project includes a reusable client component for Next.js that handles token storage from URL parameters.

TokenHandler Component

The TokenHandler component is designed to:

  1. Extract a token from URL parameters
  2. Store the token in localStorage
  3. Redirect the user to a specified path

Usage

import TokenHandler from '@/components/TokenHandler';

export default function AuthCallbackPage() {
  return (
    <div>
      <h1>Authentication Callback</h1>
      <TokenHandler 
        redirectPath="/dashboard" 
        tokenParamName="token" 
        storageKey="auth_token" 
      />
    </div>
  );
}

Props

The component accepts the following props:

  • redirectPath (optional): Path to redirect after storing token (default: '/')
  • tokenParamName (optional): Name of the URL parameter containing the token (default: 'token')
  • storageKey (optional): Key to use when storing in localStorage (default: 'auth_token')

Example URL

After authentication, redirect users to:

https://your-domain.com/auth/callback?token=your-auth-token

Implementation Details

  • Uses Next.js's useSearchParams hook to access URL parameters
  • Uses useRouter for client-side navigation after token storage
  • Includes error handling for localStorage operations
  • Displays a loading message while processing

Security Considerations

  • This implementation assumes the token is passed securely
  • Consider using HTTPS to prevent token interception
  • For enhanced security, consider using HTTP-only cookies instead of localStorage
  • The token in the URL might be visible in browser history and server logs

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.