A Gatsby #FuncJam submission, created by Nicholas Martin - an A/B testing / feature flag platform made with โ and FaunaDB! You can find most details on the demo site
-
Start developing.
To get started clone this repo locally and run
yarn install
to add all necessary packages.You will also need to set up the FaunaDB environment variables in
.env.development
. Notably, you will need to setFAUNADB_SECRET
.yarn install yarn develop
-
Open the code and start customizing!
Your site is now running at http://localhost:8000! You can use the UI on the index page to test the functions or directly access them at http://localhost:8000/api/form
Try editing the function in
src/api/form.ts
or form atsrc/pages/index.js
-
Deploy
You can deploy this example on Gatsby Cloud by copying the example into a new repo and connecting that to Gatsby Cloud.
I misread the documentation (https://www.gatsbyjs.com/docs/reference/functions/routing/) as I thought I could use dynamic routes using square brackets, eg. /api/[userId]
, similar syntax to client-only routes. Oddly enough, it works locally, even when serving a build, but doesn't work in Gatsby Cloud... sad face emoji
res.params.userId
is undefined, but oddly the path is still correctly routed...
For now, I switched to using query, but left in the original dynamic path for visibility.
- Add installation documentation to the README
- Update the
/api
folder with your function - Submit your theme at https://gatsbyjs.com/func-jam-21/
Read the Gatsby functions docs. Check out this video all about Gatsby functions Take a look at the Functions Use Cases over here.