loading...
Cover image for Jamstack Ecommerce + FaunaDB = 2 minute deployments

Jamstack Ecommerce + FaunaDB = 2 minute deployments

mattvb91 profile image Matthias von Bargen ・2 min read

Sometime last year we decided we wanted to build a serverless webshop using Next.js & GraphQL. A year later and we have not only the core proof of concept up and running but instead have managed to build a scaffolding for jamstack applications using Stencil.js and FaunaDB to power the backend.

The end result currently looks like this:

Alt Text

In realtime its just over 2 minutes for the following:

  • Create a new FaunaDB instance.
  • Generate some faker data to populate it.
  • Set up a new Vercel deployment of the sample next.js DerShop template
  • Vercel generates SSR pages and pushes them into the Vercel CDN

1 Lambda to rule them all.

The resulting build drops a /api/graphql endpoint as a lambda function into our deployment.

This means we have a static deployment of all our current data + we can realtime fetch data through our GraphQL endpoint which in turn gets its data from FaunaDB.

The end result of our queries is then cached using the Vercel CDN which in turn reduces reads on your FaunaDB instance. The caching is controller through our GraphQL schema using the @cacheControl annotation for the Apollo Server.

What next?

We currently have our Stencil application building to React output targets. We also want to support all the Stencil output targets available and create sample repositories based on these.

Our next major goal over the coming weeks will be to implement payment processing and further tidy up our overall application structure and components.

Feel free to follow our progress on github over here.

Discussion

pic
Editor guide