A presentation at JAMstack_conf London in in London, UK by Sarah Drasner
S TAT E O F T H E JA M S TAC K N AT I O N
S TAT E O F T H E JA M S TAC K N AT I O N
Ethernet
JAMstack • JavaScript • API • Markup
DNS BROWSER CDN D ATA B A S E LOAD BALANCER CLOUD STORAGE CACHING SERVICE WEB APP SERVERS JOB QUEUE JOB SERVERS SERVICES
DNS BROWSER CDN
DNS BROWSER CDN SERVICES
JAMstack A modern architecture — Create fast and secure sites and dynamic apps with JavaScript, APIs, and prerendered Markup, … served without web servers.
SA RA H D RAS N E R @ SA RA H _ E D O
DNS BROWSER CDN SERVICES
• Nuxt (Vue.js) • Next (React.js) • Gatsby (React.js) • Eleventy (Vanilla JS) • Jekyll (Ruby) • Hugo (Go) • More and more…
• Contentful • Forestry • Sanity • Netlify CMS • CraftCMS • Decoupled Wordpress • Decoupled Drupal • More and more…
Netlify Function Stripe Vuex Store Layouts Pages Components
Vue Single File Components <template> <div></div> </template> <script> export default { } </script> <style scoped> </style> @sarah_edo
Templates in the pages directory <nuxt-link to=”/product”>Product</nuxt-link> @sarah_edo
Deployed! @sarah_edo
Netlify Function Stripe Vuex Store Layouts Pages Components
functions/index.js exports.handler = async (event, context) =>” { return { statusCode: 200, body: JSON.stringify({ message: “Hi there Tacos”, event }) } } netlify.toml [build] functions = “functions”
yarn add dotenv require(“dotenv”).config() const stripe = require(“stripe”)(process.env.STRIPE_SECRET_KEY), headers = { “Access-Control-Allow-Origin”: “*”, “Access-Control-Allow-Headers”: “Content-Type” }
exports.handler = async (event, context) =>” { if (!event.body || event.httpMethod !==$$ “POST”) { return { statusCode: 400, headers, body: JSON.stringify({ status: “invalid http method” }) } } const data = JSON.parse(event.body) if (!data.stripeToken || !data.stripeAmt || !data.stripeIdempotency) { console.error(“Required information is missing.”) } return { statusCode: 400, headers, body: JSON.stringify({ status: “missing information” }) }
// stripe payment processing begins here try { await stripe.customers .create({ email: data.stripeEmail, source: data.stripeToken }) .then(customer =>” { console.log( starting the charges, amt: ${data.stripeAmt}, email: ${data.stripeEmail}
) return stripe.charges .create( { currency: “usd”, amount: data.stripeAmt, receipt_email: data.stripeEmail, customer: customer.id, description: “Sample Charge” }, { idempotency_key: data.stripeIdempotency } ) .then(result =>” { console.log(Charge created: ${result}
) }) })
Netlify Function Stripe Vuex Store AppCard.vue Layouts Pages Components
yarn add vue-stripe-elements-plus
AppCard.vue pay() { createToken().then(data =>” { const stripeData = { data, stripeEmail: this.stripeEmail }; this.$store.dispatch(“postStripeFunction”, stripeData); }); },
Vuex store export const actions = { async postStripeFunction({ getters, commit }, payload) { commit(“updateCartUI”, “loading”) try { await axios .post( “https://ecommerce-netlify.netlify.com/.netlify/functions/index”, { stripeEmail: payload.stripeEmail, stripeAmt: Math.floor(getters.cartTotal * 100), //it expects the price in cents stripeToken: “tok_visa”, //testing token, later we would use payload.data.token stripeIdempotency: uuidv1() //we use this library to create a unique id }, { headers: { “Content-Type”: “application/json” } } ) .then(res =>” { if (res.status ===&& 200) { commit(“updateCartUI”, “success”) setTimeout(() =>” commit(“clearCart”), 3000) …
Success!
DEMO github.com/sdras/ecommerce-netlify REPO ecommerce-netlify.netlify.com @sarah_edo
• Centered around a developer friendly, Git-based workflow • Designed modularly, consuming other services via APIs • Prebuilt and optimized before being served • Globally distributed and resilient to heavy traffic
• Better performance • Reduced operations cost • Increased security • Cheaper, easier scaling
• 65% LESS EXPENSIVE • AV E R A G E S E R V E R C O N N E C T I O N T I M E + 5 7 %
6x faster N E T L I F Y. C O M / C A S E - S T U D I E S / S M A S H I N G /
What are you going to build?
Thank you! @sarah_edo
An update on the evolving tools, potential, ecosystem, and community associated with the JAMstack
The following resources were mentioned during the presentation or are useful additional information.
Repo for Nuxt/Vue ecommerce store with Netlify Functions
Ecommerce app made with Nuxt, Vue, and Netlify Functions
Here’s what was said about this presentation on social media.
Inspiring and entertaining first talk by Sarah Drasner from Netlify - what's so good about JAMstack? @sarah_edo @netlify @jamstackconf #JAMStack pic.twitter.com/TKuTRZElbG
— Beth Learns To Code (@beth_code) July 10, 2019
Watching @sarah_edo present the opening keynote at @jamstackconf London is a huge treat. And then she starts showing us how she rapidly built and deployed a #jamstack dynamic e-commerce site with @nuxt_js, @stripe and @netlify. Bloody incredible! pic.twitter.com/M98ZZkWGFh
— Phil Hawksworth @ JAMstackConf London (@philhawksworth) July 10, 2019
First time seeing @sarah_edo chat live. Sarah, you didn't disappoint in the slightest! Including the business case for JAMstack and not just why it's exciting for developers was a very nice addition. Hats off and a massive thank you! #JAMstackLondon #JamStack
— Michael Wilkinson (@MichaelW_PWC) July 10, 2019
"With so many amazing tools and very less barrier to get started, what are YOU going to build?" - @sarah_edo inspired us all at #jamstack
— Anushree Subramani @ JAMStack Conf 🇬🇧 (@imAnushree) July 10, 2019
On a side note, after years of watching her talks on YouTube, I finally got to watch @sarah_edo talk live! 🎉🥳 pic.twitter.com/rB7aBW3u5q
.@sarah_edo talking about state of JAMStack @jamstackconf #London .. Deploy without the need of web servers with #JAMstack pic.twitter.com/wTuhjtSfr8
— Piyuesh kumar (@piyuesh23) July 10, 2019
@sarah_edo discussing how #jamstack isn’t necessarily a totally new concept but rather an elegant abstraction of how we’ve been working on the web by leveraging serverless functions, cdns and the browser with notable performance implications. pic.twitter.com/NGWCUonpRU
— Amy (@amyloulala) July 10, 2019
So @citrix moved their documentation off a #monolith to @jamstack and are now saving $ 65%...@jamstackconf #WomenInSTEM #womenintech #WomenWhoCode @sarah_edo #JamStack #JAMstackLondon pic.twitter.com/sxaEWFVUbS
— Suze Shardlow @JAMstackconf London 😀 (@SuzeShardlow) July 10, 2019
I've been looking forward to this day ever since i heard about @jamstackconf happening in London from @philhawksworth pic.twitter.com/Yp57e1dTTi
— Anushree Subramani @ JAMStack Conf 🇬🇧 (@imAnushree) July 10, 2019
#JAMstack has begun! Such a cool venue! And I love hearing @philhawksworth & @sarah_edo on stage! pic.twitter.com/gkYjwx5ZEk
— Una Kravets @ JAMstackConf 👩🏻💻 (@Una) July 10, 2019
Full room for @sarah_edo's state of the JAMstack at #JAMstackLondon pic.twitter.com/6l0ikPJdw2
— Matt Biilmann (@biilmann) July 10, 2019
And @sarah_edo is first up. Of course she is brilliant as always. #JAMStackLondon
— Chris Bach (@Chr_Bach) July 10, 2019
We kicked off @jamstackconf London with @sarah_edo’s keynote on “The State of JAMstack nation” #JAMStackConfLondon pic.twitter.com/vqor8k2cMN
— Christian Nwamba (@codebeast) July 10, 2019
“Hi there tacos” 🌮🌮🌮 from the very first #JAMStackLondon with the amazing @sarah_edo 🤩 pic.twitter.com/4iqsplz4U0
— Simona Cotin @ JAMstack London (@simona_cotin) July 10, 2019
@sarah_edo detailing hooking up payments into a JAMstack project 👌 pic.twitter.com/LlCmcxDFuy
— Scott @ JAMstack London 🇬🇧 (@spences10) July 10, 2019
Packed house for @sarah_edo to kick off #JAMStackLondon with an update on the state of JAMstack 🙏🏼 pic.twitter.com/hbRzitCyYe
— Josh @ JAMstackconf_ldn ⚡️ (@dzello) July 10, 2019
@sarah_edo’s slide for “abstraction” is 🎯 pic.twitter.com/ZXBzgtnE4U
— knut @ JAMstack_conf London 🇬🇧 (@kmelve) July 10, 2019
iPhone. Ethernet. And now #JAMStack. Revolutions do not invent something new, they take separate parts, and combine them in a revolutionary way. @sarah_edo @jamstackconf pic.twitter.com/DGODaJQjsf
— Nicolas @ JAMStack London (@Phacks) July 10, 2019
Finally get to see @sarah_edo speak! 😍 pic.twitter.com/vCJCBlWenh
— ingrid.e (@ingridepure) July 10, 2019
Back of the room view! @jamstackconf talks are off to a running start with @sarah_edo :) #JamStack #JAMstackLondon pic.twitter.com/cB7XaQPS7I
— perry @ jamstackconf london 🌈 (@perrysetgo) July 10, 2019
Next up it's @sarah_edo of @Netlify 😀
— Suze Shardlow @JAMstackconf London 😀 (@SuzeShardlow) July 10, 2019
"The @Apple #iPhone was not original. It didn't create something out of nothing. It combined several pieces of existing functionality into one device that fits in your hand."#WomenInSTEM #WomenWhoCode #womenintech #jamstack @jamstackconf pic.twitter.com/a5koSNgKOP
It’s time for the state of the jamstack nation with @sarah_edo! pic.twitter.com/d6xGBF0eFh
— knut @ JAMstack_conf London 🇬🇧 (@kmelve) July 10, 2019
Kicking off @jamstackconf London with @sarah_edo and the State of the JAMStack Nation.
— eli schutze @JAMStackConf (@elibelly) July 10, 2019
Should be a good day! pic.twitter.com/9iT7RVbr1y
omg sarah pic.twitter.com/8MFM5WFor3
— eli schutze @JAMStackConf (@elibelly) July 10, 2019
First up @sarah_edo talk on state of the JAMstack Nation #JamStack #JAMstackLondon @jamstackconf @Netlify pic.twitter.com/KkGnoeybsM
— Uniform (@uniform__design) July 10, 2019