Practical Next - Js For E-Commerce: Create E-Commerce Sites With The Next - Js Framework 1st Edition Alex Libby PDF Download
Practical Next - Js For E-Commerce: Create E-Commerce Sites With The Next - Js Framework 1st Edition Alex Libby PDF Download
https://ebookmass.com/product/practical-next-js-for-e-commerce-create-e-
commerce-sites-with-the-next-js-framework-1st-edition-alex-libby/
https://ebookmass.com/product/practical-next-js-for-e-commerce-create-
e-commerce-sites-with-the-next-js-framework-1st-edition-alex-libby-2/
https://ebookmass.com/product/trade-commerce-and-the-state-in-the-
roman-world-andrew-wilson/
https://ebookmass.com/product/a-world-safe-for-commerce-american-
foreign-policy-from-the-revolution-to-the-rise-of-china-dale-c-
copeland/
Developing Web Components with Svelte: Building a Library
of Reusable UI Components 1st Edition Alex Libby
https://ebookmass.com/product/developing-web-components-with-svelte-
building-a-library-of-reusable-ui-components-1st-edition-alex-libby/
https://ebookmass.com/product/practical-electronic-design-for-
experimenters-louis-e-frenzel/
https://ebookmass.com/product/developing-web-components-with-svelte-
building-a-library-of-reusable-ui-components-2nd-edition-alex-libby/
https://ebookmass.com/product/practical-musculoskeletal-ultrasound-e-
book-2nd-edition-ebook-pdf/
Alex Libby
Practical Next.js for E-Commerce: Create E-Commerce Sites with the Next.js
Framework
Alex Libby
BELPER, UK
Introduction������������������������������������������������������������������������������������������������������������xix
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 349
xi
About the Author
Alex Libby is a front-end web developer and seasoned computer book author from
England. His passion for all things open source dates back to the days of his degree
studies when he first came across web development and he has been hooked ever
since. When he isn’t busy developing new features or fixing website bugs for his day job,
Alex enjoys tinkering with different open source libraries to see how they work. He has
spent a stint maintaining the jQuery Tools library and enjoys writing about open source
technologies, principally for front-end UI development.
xiii
About the Technical Reviewer
Massimo Nardone has more than 25 years of experience
in security, web and mobile development, cloud, and
IT architecture. His true IT passions are security and
Android. He has been programming and teaching how to
program with Android, Perl, PHP, Java, VB, Python, C/C++,
and MySQL for more than 20 years. He holds a Master of
Science degree in Computing Science from the University of
Salerno, Italy.
He has worked as a CISO, CSO, security executive, IoT
executive, project manager, software engineer, research
engineer, chief security architect, PCI/SCADA auditor, and senior lead IT security/cloud/
SCADA architect for many years. His technical skills include security, Android, cloud,
Java, MySQL, Drupal, Cobol, Perl, web and mobile development, MongoDB, D3, Joomla,
Couchbase, C/C++, WebGL, Python, Pro Rails, Django CMS, Jekyll, Scratch, and more.
He worked as visiting lecturer and supervisor for exercises at the Networking
Laboratory of the Helsinki University of Technology (Aalto University). He holds four
international patents (PKI, SIP, SAML, and Proxy areas). He is currently working for
Cognizant as head of cyber security and CISO to help both internally and externally with
clients in areas of information and cyber security, like strategy, planning, processes,
policies, procedures, governance, awareness, and so forth. In June 2017, he became a
permanent member of the ISACA Finland Board.
Massimo has reviewed more than 45 IT books for different publishing companies
and is the co-author of Pro Spring Security: Securing Spring Framework 5 and Boot
2-based Java Applications (Apress, 2019), Beginning EJB in Java EE 8 (Apress, 2018), Pro
JPA 2 in Java EE 8 (Apress, 2018), and Pro Android Games (Apress, 2015).
xv
Acknowledgments
Writing a book can be a long but rewarding process; it is not possible to complete
it without the help of other people. I would like to offer a huge vote of thanks to my
editors – in particular, Gryffin Winkler, Nirmal Selvaraj, and James Robinson-Prior; my
thanks also to Massimo Nardone as my technical reviewer, James Markham for his help
during the process, and others at Apress for getting this book into print. All have made
writing this book a painless and enjoyable process, even with the edits!
My thanks also to my family for being understanding and supporting me while
writing. I frequently spend a lot of late nights writing alone, or pass up times when I
should be with them, so their words of encouragement and support have been a real
help in getting past those bumps in the road and producing the finished book that you
now hold in your hands.
Lastly, it is particularly poignant that the book was written at a time where the world
has emerged from events of an unprecedented nature, and is still finding the new norm.
It was too easy to think about those who lost the greatest thing we as humans could ever
have; life hasn’t been easy for anyone. Having a project to work on, no matter how simple
or complex it might be, has helped me get through those tough times and with the hope
that we face a new, improved, and better future.
xvii
Introduction
Practical Next.js for E-Commerce is for people who want to learn how to quickly
create e-commerce sites that are efficient and fast using the Next.js framework and
associated tools.
This project-oriented book simplifies the setting up of a Next.js-based e-commerce
site as a basis for developing an offer that we can customize to our needs, for any
future project. It will equip you with a starting toolset that you can use to create future
e-commerce offerings and incorporate the processes into your workflow, and that will
allow you to take your sites to the next level.
Throughout this book, I’ll take you on a journey through creating the base skeleton
of our site, before adding products, a checkout and payment process, and styling the
site. We will also touch on subjects such as adapting the offer for mobile devices, testing
elements of the site, and deploying into production – showing you how easy it is to
develop a starting website that we can augment later quickly. With the minimum of fuss
and plenty of practical exercises, we’ll focus on topics such as building the functionality,
styling, testing in a self-contained environment, and more – right through to producing
the final result viewable from any browser!
Practical Next.js for E-Commerce uses nothing more than standard JavaScript (upon
which React/Next.js is based), CSS and HTML, three of the most powerful tools available
for developers: you can enhance, extend, and configure any part of your website as
requirements dictate. With Next.js, the art of possible is only limited by the extent of your
imagination and the power of JavaScript tools available in any browser!
xix
PART I
In the Beginning
PART II
Getting Started
I’m not a betting man – indeed, I can’t remember the last time I placed any form of
bet, even if it was in a game! But – I will bet you one thing: over the previous few years
(say five, for argument’s sake), you purchase more online than in a brick-and-mortar
outfit, right?
Chances are that I’ve probably lost that bet (I did say I’m not a betting man). Still, the
reality is that we live in an age where e-commerce is big business and that not having any
form of e-commerce website offer means you lose business daily. The need for an online
site has become particularly acute over the last two to three years, with the horrific events
of the pandemic – businesses of all sizes have had to adapt to a new world of selling online.
But what does this have to do with a book about Next.js and e-commerce, I hear you
ask? Simple – today’s customers are time-poor and expect sites to be fast, reliable, and,
above all, simple to use. It’s a tall order, right?
It’s not as large as you might think: welcome to the world of SPAs, or single-page
applications. As a concept, it’s not clear when these came into being, but there are
reports that it could have been as far back as 2003, so not a new concept. However, it’s
taken off over the last few years in frameworks or libraries such as React, Angular, Vue,
and of course, Next.js!
Over these following few pages, I’ll take you through what makes single-page
applications a perfect fit for e-commerce websites and why this benefits customers and
companies. We’ll also look at how Next.js makes an excellent basis for what will become
our project for this book.
There are lots of reasons from both a developer and business perspective – we’ll look
at the business side in a moment, but let’s first take a look at some of the advantages for
us developers:
• We can reduce load times through the use of concepts such as lazy
loading and automatic code splitting – this helps maintain excellent
performance, a great user experience, and faster time to market.
I know there are some downsides, though, from a developer’s perspective. Some
people find Next.js too opinionated as a framework, although its abstraction of many
features to simplify the development process means it has to decide a few things for us!
Some people are also not keen on the routing it uses; it is page-based, which makes
it very easy (and removes the need for dedicated routing code), although it does dictate
how you need to set up the routing!
Okay – that all aside, let’s move on. As a developer, you’ve chosen to use Next.js
(and, therefore, this book) as you like the look of what you see. However, one important
subject we need to cover is how we sell the benefits of Next.js to those who control the
purse strings. There are several reasons to choose Next.js, so let’s take a moment to look
at these in more detail.
4
Chapter 1 Getting Started
Yes, this is probably the most important part: there is no sense in trying out new
technology if we don’t have buy-in from the business! Fortunately, this is one of those
occasions where we shouldn’t have a problem with selling the benefits of Next.js – there
are some great reasons why we (as the business) should make the transition to using this
framework:
• Short page load time – Static websites are fast by nature, so visitors
and customers will be content with the performance of NextJS
websites and web apps.
Silv. Por mi vida, señora Lozana, que creo que si fuérades vos la
misma teoría no dixérades más de lo dicho, mas quiero que sepais
que la taberna meritoria para esas señoras ya está hecha
archihospital, y la honra, ayuda y triunfo que ellas dan al Senato es
como el grano que siembran sobre las piedras, que como nace se
seca, y si oistes decir que antiguamente cuando venía un romano ó
emperador con victoria, lo llevaban en un carro triunfante por toda
la ciudad de Roma, y esto era gran honra, y en señal de forteza una
corona de hojas de roble, y él asentado encima, y si alguna señal
tenía de las heridas que en las batallas y combates hobiese
rescebido, la mostraba públicamente, de manera que entónces el
carro y la corona y las heridas eran su gloria, y despues su
renombre, fama y gloria. ¿Qué mejor ni más largo os lo puedo yo
dar á entender, señora Lozana, de lo que vos misma podeis ver? que
como se hacen francesas ó grimanas, es necesario que en muerte ó
en vida vayan á Santiago de las Carretas, y allí el carro y la corona
de flores y las heridas serán su mérito y renombre á las que vernán,
las cuales tomarán audibilia pro visibilia; ansí que, señora Lozana, á
vos no ha de faltar sin ellas de comer, que ayer hablando con un mi
amigo hablamos de lo que vos alcanzais á saber, porque me recordé
cuando nos rompistes las agallas á mí y á cuantos estábamos en el
banco de ginoveses.
Loz. Y si entónces las agallas, agora los agallones, y oidme dos
razones.
MAMOTRETO XLVI.
ebookmasss.com