Skip to content

Commit

Permalink
chore(nextjs): Introduce build-time error for server-only helpers on …
Browse files Browse the repository at this point in the history
…client-side (#3758)
  • Loading branch information
LauraBeatris authored Jul 18, 2024
1 parent 20497e9 commit 18bcfbc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-chairs-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/nextjs": patch
---

Return build-time error if `auth` and `currentUser` server-side helpers are imported into Client Components.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@clerk/types": "4.8.0",
"crypto-js": "4.2.0",
"path-to-regexp": "6.2.2",
"server-only": "0.0.1",
"tslib": "2.4.1"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/src/app-router/server/auth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'server-only';

import type { AuthObject, RedirectFun } from '@clerk/backend/internal';
import { constants, createClerkRequest, createRedirect } from '@clerk/backend/internal';
import { notFound, redirect } from 'next/navigation';
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/src/app-router/server/currentUser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'server-only';

import type { User } from '@clerk/backend';

import { clerkClient } from '../../server/clerkClient';
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/src/server/__tests__/exports.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jest.mock('server-only', () => null);

import * as publicExports from '../index';

describe('/server public exports', () => {
Expand Down

0 comments on commit 18bcfbc

Please sign in to comment.