Unresolvable Alias “@/lib/auth-context” Import Loop

Hello Vercel Community,

I’m completely stuck after restoring snapshot v467 via the v0.dev LLM. My Next.js project uses path aliases in tsconfig.json (e.g. @/lib/, @/hooks/), but I can’t get my authentication hook to resolve:

  • Implementation:
    • Hook lives in lib/auth-context.tsx and is exported as useAuth.
    • I created hooks/use-auth.ts to re-export from @/lib/auth-context.
  • What I’ve tried:
    1. Switching imports between @/lib/auth-context, ../lib/auth-context and @/hooks/use-auth.
    2. Adjusting paths in tsconfig.json / jsconfig.json to map @/* → ["./"], @/lib/ → ["lib/"], @/hooks/ → [“hooks/*”].
    3. Verifying file structure and casing on disk.
  • Current error:

The file “@/lib/auth-context” cannot be found (imported in “/hooks/use-auth”).

No matter how I reconfigure aliases or imports, the build/runtime throws “file not found.” I’ve spent dozens of AI-generated prompt attempts with no success.

Request:

Could someone please share a working example of Next.js path-alias setup for redirecting @/hooks/use-auth to lib/auth-context.tsx? Any pointers on tsconfig/jsconfig, folder structure, or import syntax that definitively breaks this loop would be hugely appreciated.

Thank you!

— Alexander

Hey, @iamalextremo!

Have you got any chat examples? It’d help us dig a bit deeper.

One thing to check is to make sure you’re not including the .tsx extension in your import:

import { useAuth } from '@/lib/auth-context'

Let us know how you get on!