GithubHelp home page GithubHelp logo

Comments (3)

ajayvignesh01 avatar ajayvignesh01 commented on May 28, 2024 1

If that's the only component that's causing it, you can change that part to use either SWR or useEffect like this:

SWR

  const supabase = createClientComponentClient()
  
  const getUser = async () => {
    const { data: { user } } = await supabase.auth.getUser()
    return user
  }

  const { data: user } = useSWRImmutable('getUser', getUser)

useEffect

const [user, setUser] = useState<User>()

useEffect(() => {
  const supabase = createClientComponentClient()

  async function getUser() {
    const { data: { user } } = await supabase.auth.getUser()
    return user
  }

  getUser().then((user) => setUser(user))
}, [])

Make sure you 'use client' at top of page and import the necessary modules.

from nextjs-subscription-payments.

EpicDevv avatar EpicDevv commented on May 28, 2024

Thank you for your prompt reply. I was wondering if there is a way to retain the supabase request for user information on the server, while also being able to statically generate or cache the rest of the page. I believed that Next.js 13 made this possible. Can I keep the navbar as it is, but use generateStaticParams for multiple static pages to be pre-built beforehand?

from nextjs-subscription-payments.

chriscarrollsmith avatar chriscarrollsmith commented on May 28, 2024

Thank you for your prompt reply. I was wondering if there is a way to retain the supabase request for user information on the server, while also being able to statically generate or cache the rest of the page. I believed that Next.js 13 made this possible. Can I keep the navbar as it is, but use generateStaticParams for multiple static pages to be pre-built beforehand?

At the top of each page or component, you can add 'use client' or 'use server' as desired. Typically you want server components to be above client components in the tree, but technically I believe you can chain them however you want.

But for static content, why wouldn't you want them to be rendered server-side? Rendering static content is, like, one of the main use cases for SSR.

from nextjs-subscription-payments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.