front matter

preface

I have been a professional software developer for 37 years and a web developer for around 10 years. My projects have used many technologies and frameworks, including raw DOM manipulation, jQuery, Ruby, Angular 1, React, Polymer, Angular 2+, Vue, Svelte, and probably some I have forgotten.

I place a high value on developer productivity. Unnecessary complexity really works against this. While I find many things to love about Svelte and Sapper, the main driver for me is their simplicity compared to other web development approaches. I know from my experience of using other frameworks that I am far more productive when using Svelte and Sapper.

My first exposure to Svelte came from watching a talk titled “Rethinking Reactivity” by the creator of Svelte, Rich Harris. It is a very compelling talk and definitely appealed to my desire to reduce the complexity of web development. That led me to dig in further, write a long article about Svelte, give talks at user groups, and expand to giving talks at conferences. The next logical step was to write this book!

The book covers nearly every topic related to Svelte and Sapper, and some that are only tangentially related. After reading this, you should be well-poised to use these tools in your next web development project.

acknowledgments

Many authors thank their spouses for the patience they showed during the writing process. The experience of writing this book has made clear to me the sacrifices involved. My wife Tami generously gave me lots of encouragement and time to complete this project. Thank you so much Tami for helping me to achieve the goal of finally writing a book!

Thanks to my Manning development editor, Jennifer Stout, who provided just the right amount of corrections, suggestions, encouragement, and compliments to keep me going. Seeing comments like “I love this!” mixed in with comments like “You need to explain why someone would want to do this” made the writing process so much more bearable.

Thanks to Manning technical editor Alain Couniot who continually pointed out when I wasn’t being clear or was short on providing compelling examples. He also made sure I mentioned TypeScript wherever possible. The book is much better because of his feedback!

Thanks to Manning technical reviewer Erik Vullings. He tried many things in the example code that never crossed my mind to try and suggested many improvements in the text. His thoroughness was greatly appreciated!

Thanks to Peer Reynders, a volunteer MEAP reviewer who went through all the code examples with a fine-tooth comb and pointed out many ways I could improve it.

Thanks to reviewers who added their own takes on ways to improve the book: Adail Retamal, Amit Lamba, Clive Harber, Damian Esteban, David Cabrero Souto, David Paccoud, Dennis Reil, Gerd Klevesaat, Gustavo Filipe Ramos Gomes, Jonathan Cook, Kelum Senanayake, Konstantinos Leimonis, Matteo Gildone, Potito Coluccelli, Robert Walsh, Rodney Weis, Sander Zegveld, Sergio Arbeo, and Tanya Wilke. More eyes and more opinions definitely helped!

Thanks to Charles Sharp of Object Computing, Inc. He has been the most frequent editor of all my previous writings. Charles donated large amounts of time over past 10 plus years to making me a better writer . . . Oxford comma and all!

Thanks to Eldon Ahrold of Object Computing, Inc. for reviewing the chapter on Svelte Native. Eldon is a very experienced mobile and web developer, and I’m lucky to be able to bounce ideas off of him.

Finally, thanks to Dr. Ebrahim Moshiri who hired me into Object Computing, Inc. 24 years ago. He provided me with an environment that encourages continual learning and I’ve never stopped. I most likely would not have been in a position to write this book if it wasn’t for the career he gave me.

about this book

Who should read this book

Svelte and Sapper in Action is for web developers who want to increase their productivity. Maybe you have a nagging suspicion that there must be an easier way to develop web applications. Good news--there is, and you will learn about it here!

Through numerous code examples, you will learn how to use Svelte and Sapper to implement many common features of web applications.

The book assumes that readers have a basic familiarity with HTML, CSS, and JavaScript:

I am easy to find online, should you have questions about anything in the book. My hope is that by the time you make it through this book, you will be convinced that there is something special about Svelte and Sapper. These are technologies that deserve a shot at being used in your next project.

How this book is organized: A roadmap

This book is divided into 4 parts containing a total of 21 chapters.

Part 1 introduces Svelte and Sapper.

Part 2 dives deep into Svelte, providing thorough coverage along with lots of example code.

Part 3 explores Sapper in depth. Sapper builds on Svelte to add many features.

Part 4 goes beyond Svelte and Sapper.

The learning doesn’t stop after the last chapter! The seven appendixes contain important information.

Throughout the book we’ll develop a Travel Packing application. Most chapters add features to the app based on the topics they cover.

Readers who are new to Svelte should read chapters 1 through 8 before skipping to any of the later chapters. These cover the core principles of Svelte. Readers with previous Svelte experience can skip to chapters of interest.

About the code

Much of the code in the book can be found in the author’s GitHub repositories at https:// github.com/mvolkmann. In particular, see https://github.com/mvolkmann/svelte-and-sapper-in-action and https://github.com/mvolkmann/svelte-native-components.

To run the code, you will need to install a recent version of Node.js. If you do not already have this installed, browse to https://nodejs.org/ and click either the LTS or Current button to download it.

This book contains many examples of source code both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes code is also in bold to highlight code that has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code.

In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, even this was not enough, and listings include line-continuation markers (). Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts.

liveBook discussion forum

Purchase of Svelte and Sapper in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to https://livebook.manning.com/#!/book/svelte-and-sapper-in-action/ discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/#!/discussion.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

Other online resources

Appendix A lists a large number of online resources. Most of these are directly related to Svelte and Sapper, but some cover topics applicable to all varieties of web development.

about the author

R. Mark Volkmann is a partner at Object Computing, Inc. (OCI) in St. Louis, where he has provided software consulting and training since 1996. As a consultant, Mark has assisted many companies with JavaScript, Node.js, Svelte, React, Vue, Angular, and more. Mark has created and taught many courses on topics including React, Vue, AngularJS, Node.js, jQuery, JavaScript, HTML5, CSS3, Ruby, Java, and XML. He is a frequent presenter at St. Louis-area user groups. He has presented at many conferences, including Nordic.js, Jfokus, NDC Oslo, Strange Loop, MidwestJS, No Fluff Just Stuff, and XML DevCon. Mark frequently writes articles on various software development topics. These can be found at https://objectcomputing.com/resources/publications/mark-volkmann.

In his spare time, Mark likes to run. To date he has run 49 marathons in 39 states.

about the cover illustration

The figure on the cover of Svelte and Sapper in Action is captioned “femme Corfiote,” or a woman from the island of Corfu, in Greece. The illustration is taken from a collection of dress costumes from various countries by Jacques Grasset de Saint-Sauveur (1757-1810), titled Costumes de Différents Pays, published in France in 1797. Each illustration is finely drawn and colored by hand. The rich variety of Grasset de Saint-Sauveur’s collection reminds us vividly of how culturally apart the world’s towns and regions were just 200 years ago. Isolated from each other, people spoke different dialects and languages. In the streets or in the countryside, it was easy to identify where they lived and what their trade or station in life was just by their dress.

The way we dress has changed since then and the diversity by region, so rich at the time, has faded away. It is now hard to tell apart the inhabitants of different continents, let alone different towns, regions, or countries. Perhaps we have traded cultural diversity for a more varied personal life--certainly for a more varied and fast-paced technological life.

At a time when it is hard to tell one computer book from another, Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional life of two centuries ago, brought back to life by Grasset de Saint-Sauveur’s pictures.