Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve support for OnchainKit in Next.js 14+ apps #1771

Merged
merged 7 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ docs/.vitepress/dist

*storybook.log
storybook-static/

# Tarballs
*.tgz
17 changes: 17 additions & 0 deletions packemon.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ const config = {
},
]);
},

// Adding support for React 18's "use client" directive
// Mostly used with Next.js apps
rollupOutput(config) {
config.plugins.push({
name: 'fix-use-client',
renderChunk(code) {
if (code.includes("'use client'")) {
// Remove the original directive and split into lines
const lines = code.replace("'use client';", '').split('\n');
// Filter out any empty lines and reconstruct
return `'use client';\n${lines.filter((line) => line.trim()).join('\n')}`;
}
return null;
},
});
},
};

export default config;
1 change: 1 addition & 0 deletions src/ui/react/identity/components/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { useIdentityContext } from '@/core-react/identity/providers/IdentityProvider';
import type { AddressReact } from '@/core-react/identity/types';
import { getSlicedAddress } from '@/core/identity/utils/getSlicedAddress';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { useAvatar } from '@/core-react/identity/hooks/useAvatar';
import { useName } from '@/core-react/identity/hooks/useName';
import { useIdentityContext } from '@/core-react/identity/providers/IdentityProvider';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import type { BadgeReact } from '../../../../core-react/identity/types';
import { badgeSvg } from '../../../../internal/svg/badgeSvg';
import { background, cn } from '../../../../styles/theme';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/EthBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { useIdentityContext } from '@/core-react/identity/providers/IdentityProvider';
import type { EthBalanceReact } from '@/core-react/identity/types';
import { getRoundedAmount } from '@/core/utils/getRoundedAmount';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/Identity.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { IdentityProvider } from '@/core-react/identity/providers/IdentityProvider';
import type { IdentityReact } from '@/core-react/identity/types';
import { useOnchainKit } from '@/core-react/useOnchainKit';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/IdentityCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import type { Address, Chain } from 'viem';
import { Address as AddressComponent } from './Address';
import { Avatar } from './Avatar';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/Name.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { useName } from '@/core-react/identity/hooks/useName';
import { useIdentityContext } from '@/core-react/identity/providers/IdentityProvider';
import type { NameReact } from '@/core-react/identity/types';
Expand Down
1 change: 1 addition & 0 deletions src/ui/react/identity/components/Socials.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import type { Address, Chain } from 'viem';
import { useName } from '../../../../core-react/identity/hooks/useName';
import { useSocials } from '../../../../core-react/identity/hooks/useSocials';
Expand Down
Loading