Last active
March 31, 2023 14:02
-
-
Save er2/f8a999231a550a555b9977ac2c36d582 to your computer and use it in GitHub Desktop.
HTMX plus Supabase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/htmx.org@1.8.4"></script> | |
<script> | |
document.body.addEventListener('htmx:configRequest', function(evt) { | |
const key = '<your key here>'; | |
evt.detail.headers['apikey'] = key; | |
evt.detail.headers['Authorization'] = "Bearer " + key; | |
}); | |
document.body.addEventListener('htmx:beforeSwap', function (evt) { | |
// trim quotes from response | |
evt.detail.serverResponse = evt.detail.serverResponse.slice(1, -1); | |
}); | |
</script> | |
<h2>This is an experiment with hooking up HTMX straight to Supabase</h2> | |
<div hx-post="https://<your id here>.supabase.co/rest/v1/rpc/home" | |
hx-trigger="load"> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment