Skip to content

SaaS boilerplate example with SvelteKit + Tailwind + Netlify Identity (GoTrue) + Stripe + Fauna.

Notifications You must be signed in to change notification settings

ClaytonFarr/sveltekit-netlify-stripe-fauna-example

Repository files navigation

Reference Repo for SvelteKit + Netlify Adapter

Example of code / use cases for potential updates to SvelteKit Netlify Adapter.

TL;DR

Current Netlify Adapter has 2 primary limitations:

  1. Endpoints do not have access to context.clientContext data. This contains information needed to interact with services like Netlify Identity for admin actions. Details
  2. Netlify triggers some functionality per specifically named functions (e.g. post user signup). Endpoint 'functions' are currently aggregated into a single render function, preventing specifically named endpoints/functions from being available post build. Details

Current Workarounds

  • For functionality that requires context.clientContext data, create a separate, custom serverless function that is copied post build into the final functions directory (via package.json script):
    • Example 1: /src/additional_functions/delete-identity.js (a function called explicitly by SK endpoints)
    • Example 2: /src/additional_functions/handle-subscription-change.js (a webhook triggered by an external event [Stripe subscription udpate])
  • For specifically named files that are triggered by events, also create a separate custom serverless function that is copied post build into the final functions directory:
    • Example: /src/additional_functions/identity-signup.js (function called automatically when a new user completes signup process)

Package versions in use at time of writing:

  • @sveltejs/kit 1.0.0-next.115
  • @sveltejs/adapter-netlify 1.0.0-next.17

Requirements to implement repo:

  1. Create accounts if needed; can use free plan for all.
  1. Install Netlify CLI

  2. Clone repo & publish within own Git account