Of all the technologies to emerge in the web development industry in recent years, perhaps none has generated as much attention and excitement as Gatsby, a static site generator based on React. Though Gatsby is touted for its ease of use, performance benefits, and versatility for use cases both simple and complex, it’s equally vaunted for its developer experience advantages thanks to its use of GraphQL and high degree of extensibility.

When I first discovered Gatsby in 2017, the idea of the Jamstack, the architectural paradigm of which Gatsby is a prominent part, was still in its infancy. The concept of synthesizing new performance optimizations in browsers with a statically generated site hadn’t yet taken the web development world by storm. In the years since, the pattern into which Gatsby fits has become a popular strategy emulated by other ecosystems in the JavaScript and static site generator landscape.

I also have a personal connection to Gatsby, having joined the core framework team and company in 2019 to lead product management for Gatsby Cloud, the hosting infrastructure underpinning many Gatsby sites. As of this writing, Gatsby has one of the most active and knowledgeable open source communities in existence, and I’m excited to see what’s ahead in Gatsby’s future. By the end of this book, you will be too!

Who Should Read This Book

Gatsby: The Definitive Guide is a book that is intended to serve not only as an introduction to beginning, intermediate, and advanced use cases for developers working with Gatsby but also as a holistic reference to use while building Gatsby sites. To that end, it aims to be both edifying and exhaustive without veering too far to either extreme.

This book is intended for anyone in the web development world who is looking to work with Gatsby, whether you have experience with React or not. Though knowledge of JavaScript is helpful, many of the concepts that undergird Gatsby are understandable to those who have only previously worked in HTML and CSS, and Gatsby: The Definitive Guide provides a full introduction to the Jamstack pattern and an abridged primer on React and modern JavaScript.

If you’re a web designer, a web developer, or even a programmer with limited knowledge of modern web development practices, this book is an ideal way to get started with Gatsby. But it also has plenty of new information for those already well versed in Jamstack and JavaScript technologies. And if you’re looking to modernize your skill set in preparation for the coming decade of the web, this book is an excellent way to learn one of the technologies at the vanguard of frontend development.

Why I Wrote This Book

Gatsby: The Definitive Guide isn’t just the first book from O’Reilly on the topic of the Gatsby framework; it’s also the first comprehensive guide to Gatsby, covering the foundations of what makes Gatsby great and the full range of what developers can achieve with Gatsby. It’s the first-ever book that will give you a full understanding of both key elements of the Jamstack world and everything you need to equip yourself for success with Gatsby development.

As someone with a passion for both content management and modern web development, I authored this book with an eye toward enabling those who work at the intersection of cutting-edge digital experiences and leading frontend technologies. My own personal site has been powered by Gatsby for several years now, and both colleagues and casual observers have commented on its speed, despite the fact that it handles data originating from a variety of sources.

Gatsby: The Definitive Guide is also my second book focused entirely on web development, following in the footsteps of my debut Decoupled Drupal in Practice (Apress), which was the first comprehensive guide to decoupled Drupal. Just like that work, I wrote this book to provide others with the encyclopedic reference and comprehensive coverage I wish I had when I kicked off my own journey.

Conventions Used in This Book

The following typographical conventions are used in this book:

Indicates new terms, URLs, email addresses, file and directory names, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user. Also used for emphasis in program listings.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Indicates code that wraps but should not be put on a new line.

This element signifies a tip or suggestion.


This element signifies a general note.


This element indicates a warning or caution.

Using Code Examples

Supplemental material (code examples, exercises, etc.) is available for download at

If you have a technical question or a problem using the code examples, please email .

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Gatsby: The Definitive Guide, by Preston So. Copyright 2021 Preston So, 978-1-492-08751-9.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected].

O’Reilly Online Learning

For more than 40 years, O’Reilly Media has provided technology and business training, knowledge, and insight to help companies succeed.

Our unique network of experts and innovators share their knowledge and expertise through books, articles, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, visit

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.

  • 1005 Gravenstein Highway North

  • Sebastopol, CA 95472

  • 800-998-9938 (in the United States or Canada)

  • 707-829-0515 (international or local)

  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at

Email [email protected] to comment or ask technical questions about this book.

For news and information about our books and courses, visit

Find us on Facebook:

Follow us on Twitter:

Watch us on YouTube:


Without the Gatsby community and my former colleagues at Gatsby, as well as personal connections around the world, this book would never have made it past the drawing board.

First and foremost, my fond thanks to my editor Jeff Bleiel, who has been a steadfast resource and sounding board throughout the entire writing process, even at the nadir of the still-ongoing coronavirus pandemic.

My gratitude also goes to Alexander Nnakuwe and David Mackey, the book’s technical reviewers, whose comments have helped it attain a high level of quality and lasting relevance. In addition, Amanda Quinn was a spectacular resource at O’Reilly in working with me on the initial steps of this book, Katie Tozer has been fantastic to collaborate with as production editor, and Rachel Head gave this text an incredibly thorough review as copyeditor.

Second, I’d be remiss not to thank my colleagues and friends at Gatsby, who made my time there edifying along multiple dimensions and helped me grow as a writer and a product leader. Big thanks must go to Sid Chatterjee, without whom this book would never have made it past the planning stage—his ideas and suggestions were instrumental to getting this process off the ground.

I also offer my profound gratitude to the Product and Design organization at Gatsby, who were among the finest teams I’ve ever had the privilege to work for and learn from: especially Marisa Morby, Florian Kissling, and Shannon Soper. Thanks also to my other colleagues at Gatsby, particularly Nat Alison, David Bailey, Chris Biscardi, Aisha Blake, Caitlin Cashin, Obinna Ekwuno, Kurt Kemple, Jason Lengstorf, Madalyn Parker, Amberley Romo, Marcy Sutton, and Hashim Warren, all of whom deeply inspired this project with their own work and left Gatsby in a better place in ways both human and technical.

Finally, thanks to all my former and current colleagues at companies like Time Inc., Acquia, and now Oracle who have been encouraging and understanding throughout this writing process. And a fond word of support to those, like me, who have felt excluded from many aspects of the technology industry due to systemic oppression in various forms—it’s my hope that this work inspires you to contribute your important and much-needed voice to the discourse as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.