Comments (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.
- 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.
- 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.
- 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)
- Dependency resolution problems HOT 7
- Error while creating home page with fulfillAPIRequest HOT 3
- How to disable mock connector code HOT 3
- Please support saleor
- Search does not work (possible routing/API issue). HOT 3
- Is there a plan in the near future to upgrade Material UI to v5 ?
- Carousel component not passing arrows and dots classes down to the Arrows/Dots components
- Contact form broken and slack link on home page expired HOT 1
- Is the project abandoned ? HOT 6
- Add to Cart functionality issue
- Accessibility issue with Quantity Selector
- Latest version doesn't download with npm
- Upgrade docs to include steps for upgrading to latest version.
- Custom submit button component for SearchField
- How to pass translated hint texts for MagnifyHint
- Slack Invitation Expired.
- Connector Building Documentation looks Incomplete.
- Is this Project Dead? HOT 7
- Support for NextJS 13
- I cannot start the app using 'npm start' it shows 'Invalid hook call. Hooks can only be called inside of the body of a function component'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-storefront.