Giter Site home page Giter Site logo

Comments (1)

markbrocato avatar markbrocato commented on May 22, 2024
  1. What is the usage of the the api/session ? I know it can pass down the session data through the child but we can also do that with appData. Another thing is how I can update and get back session data for each user. Do I need use redis or any db to store the session and get session data back based on the id which I will set to user cookie ?

api/session is fetched when the app loads in the browser and is meant to establish a session with your ecommerce platform. How this is done depends on the platform. Generally you return any data associated with the user session. For example, the number of items in the cart.

What is the usage of useAppStore hook ? in pages/_app.js why don use appData direct from pageProps ? Why _app don use createLazyProps like another pages?

The idea is to only include app level data in the initial SSR response. For example, the data needed to build the main menu and navigational tabs. These generally don't change and thus including this data with every subsequent API response just slows things down and uses more network bandwidth. The useAppStore hook makes it easy to access this app level data from anywhere in your app at any point during the browsing flow.

  1. I want to make simple app like the shopping cart ? But I want to make the cart persistent, do I need to store using db when add to cart and in api/cart I will get the cart details out of db. ?

React Storefront is meant to be deployed on top of a headless ecommerce platform like Shopify or CommerceTools that provides the catalog, payment processing, and cart persistence for you. Those platforms typically store the user session in a database.

  1. What is the usage of appData ? I can see that for the Server side rendering, the appData handler will be call in fullfillRequestAPI but I wonder how I can set the appData when I am in one specific page which is render on client side.

App data is always provided during server side rendering and generally not updated thereafter. See my answer to 2.

  1. About the SessionContext, there is only one action is updateCartCount and it will update only in context, so how can I add more actions for session Context. Maybe I would like to have action to add product or logged user into session ?

You make a good point here - there should be a way to update session data in general. Let us think on this and figure out what changes should be made.

from react-storefront.

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.