mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-15 23:58:56 -05:00
Merge pull request #22 from neynarxyz/shreyas/neyn-5928-resolve-customer-issue-with-broken-nsk-script
Handle session provider rendering
This commit is contained in:
commit
2edd1bd2ae
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@neynar/create-farcaster-mini-app",
|
||||
"version": "1.7.7",
|
||||
"version": "1.7.8",
|
||||
"type": "module",
|
||||
"private": false,
|
||||
"access": "public",
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import type { Metadata } from "next";
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import "~/app/globals.css";
|
||||
import { Providers } from "~/app/providers";
|
||||
import { APP_NAME, APP_DESCRIPTION } from "~/lib/constants";
|
||||
import '~/app/globals.css';
|
||||
import { Providers } from '~/app/providers';
|
||||
import { APP_NAME, APP_DESCRIPTION } from '~/lib/constants';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: APP_NAME,
|
||||
@ -17,11 +17,12 @@ export default async function RootLayout({
|
||||
// Only get session if sponsored signer is enabled or seed phrase is provided
|
||||
const sponsorSigner = process.env.SPONSOR_SIGNER === 'true';
|
||||
const hasSeedPhrase = !!process.env.SEED_PHRASE;
|
||||
const shouldUseSession = sponsorSigner || hasSeedPhrase;
|
||||
|
||||
let session = null;
|
||||
if (sponsorSigner || hasSeedPhrase) {
|
||||
if (shouldUseSession) {
|
||||
try {
|
||||
const { getSession } = await import("~/auth");
|
||||
const { getSession } = await import('~/auth');
|
||||
session = await getSession();
|
||||
} catch (error) {
|
||||
console.warn('Failed to get session:', error);
|
||||
@ -31,7 +32,9 @@ export default async function RootLayout({
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>
|
||||
<Providers session={session}>{children}</Providers>
|
||||
<Providers session={session} shouldUseSession={shouldUseSession}>
|
||||
{children}
|
||||
</Providers>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@ -18,15 +18,17 @@ const WagmiProvider = dynamic(
|
||||
export function Providers({
|
||||
session,
|
||||
children,
|
||||
shouldUseSession = false,
|
||||
}: {
|
||||
session: Session | null;
|
||||
children: React.ReactNode;
|
||||
shouldUseSession?: boolean;
|
||||
}) {
|
||||
const solanaEndpoint =
|
||||
process.env.SOLANA_RPC_ENDPOINT || 'https://solana-rpc.publicnode.com';
|
||||
|
||||
// Only wrap with SessionProvider if next auth is used
|
||||
if (process.env.SPONSOR_SIGNER === 'true' || process.env.SEED_PHRASE) {
|
||||
if (shouldUseSession) {
|
||||
return (
|
||||
<SessionProvider session={session}>
|
||||
<WagmiProvider>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user