17
How-to Magento with Next.js vol 1. Getting Started Carlos A. Cabrera @fnhipster | Solutions Architect & FED Solutions Innovation

How-to Magento with Next.js vol 1. Getting Started

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: How-to Magento with Next.js vol 1. Getting Started

How-to Magento with Next.jsvol 1. Getting StartedCarlos A. Cabrera @fnhipster | Solutions Architect & FEDSolutions Innovation

Page 2: How-to Magento with Next.js vol 1. Getting Started

“I'll create a storefront while NOT learning anything about how Magento works.”

Famous last words.

Page 3: How-to Magento with Next.js vol 1. Getting Started

Why Next.js?

Page 4: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Street Cred

§ Zero Configuration. Auto code splitting, compilation and bundling. Automatic TypeScript support.

§ File-system Routing. Every component in the `pages` directory is a route.

§ Hybrid Pre-rendering. Build time with (SSG ) or request time (SSR).

§ Incremental SSG. Update existing pages by re-rendering them in the background as traffic comes in.

§ Static Exporting. It just happens. One command to build.

§ Fully Extensible. Complete control over Babel and Webpack. with Next-plugins.

§ Built-in CSS Support. CSS Modules out of the box, but it also works with other styling solutions.

§ Ready for Production. Optimized for a smaller build size.

Page 5: How-to Magento with Next.js vol 1. Getting Started

Getting Started with Next.js

Page 6: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Getting Started with Next.js

https://nextjs.org/docs/getting-started

Page 7: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Getting Started with Next.js

https://github.com/vercel/next.js/tree/canary/examples

Page 8: How-to Magento with Next.js vol 1. Getting Started

Getting Started with Magento & Next.js

Page 9: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Getting Started with Next.js + Magento

https://github.com/fnhipster/magento-with-next-sample

Page 10: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

MVP Dependencies

https://github.com/fnhipster/magento-with-next-sample/blob/main/package.json

Next.js (React) Magento GraphQL+ = 🤑🤑🤑

Page 11: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Extending Next.js

https://github.com/fnhipster/magento-with-next-sample/blob/main/next.config.js

Page 12: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Proxy API

https://github.com/fnhipster/magento-with-next-sample/blob/main/pages/api/proxy.js

Page 13: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Next.js Built-in Components

https://github.com/fnhipster/magento-with-next-sample/blob/main/components/Category/Category.js

Page 14: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

To SSG, or to SSR, that is the question.

https://github.com/fnhipster/magento-with-next-sample/blob/main/pages/index.js

getServerSideProps

Page 15: How-to Magento with Next.js vol 1. Getting Started

©2020 Adobe. All Rights Reserved. Adobe Confidential.

Routing a.k.a. Pages

§ pages/

§ api/proxy.js api end-point that proxy our front-end request to our Magento instance.

§ _app.js custom Next App container for our application. Includes, global.css and ApolloProvider

§ _url_resolver.js check the requested URL with Magento and resolve the content-type

§ PRODUCT

§ CATEGORY

§ CMS_PAGE

§ index.js our home page.

Page 16: How-to Magento with Next.js vol 1. Getting Started
Page 17: How-to Magento with Next.js vol 1. Getting Started