Skip to content

[UI] Add 'use client' directive to context files for Next.js 16 SSR compatibility#437

Merged
Nitya-003 merged 1 commit into
Nitya-003:mainfrom
Siddh2024:fix/use-client-directives
Jun 18, 2026
Merged

[UI] Add 'use client' directive to context files for Next.js 16 SSR compatibility#437
Nitya-003 merged 1 commit into
Nitya-003:mainfrom
Siddh2024:fix/use-client-directives

Conversation

@Siddh2024

Copy link
Copy Markdown
Contributor

Description

Three context files (ThemeContext, CurrencyContext, AuthContext) use React hooks (useState, useEffect, useContext) without the "use client" directive. In Next.js 16 App Router, any module using hooks must be a Client Component. If a Server Component imports these contexts, it will throw a runtime error.

Fixes issue #435

Changes Made

Added "use client"; as the first line of:

  • frontend/src/context/ThemeContext.tsx
  • frontend/src/context/CurrencyContext.tsx
  • frontend/src/context/AuthContext.tsx

Testing

  • Verified that hooks are only used in client components
  • No breaking changes to existing functionality

Three context files (ThemeContext, CurrencyContext, AuthContext) use React
hooks without the 'use client' directive. In Next.js 16 App Router, this
causes runtime errors when Server Components import them.

Added 'use client' as the first line of all three files.
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

@Siddh2024 is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Nitya-003 Nitya-003 added gssoc:approved gssoc'26 approved quality:clean *1.2 for contributor +5 pts for mentor level:intermediate 35 pts for contributor 20 pts for mentor labels Jun 18, 2026
@Nitya-003 Nitya-003 merged commit 992e43d into Nitya-003:main Jun 18, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved gssoc'26 approved level:intermediate 35 pts for contributor 20 pts for mentor quality:clean *1.2 for contributor +5 pts for mentor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants