Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supabase Auth Example #1830

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

kjrocker
Copy link

@kjrocker kjrocker commented Feb 26, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

  • Addresses an existing open issue: fixes #000
  • Tests for the changes have been added (for bug fixes / features)

What is the current behavior?

There is no complete example for how to use Supabase in SolidStart.

What is the new behavior?

Create a "complete" example of Supabase Auth with the following features

  1. A mixture of server-side and browser-side behavior
  2. Sign in, make a new account, sign out, forget password, reset password.
  3. A way to protect authenticated pages.
  4. A way to conditionally render UI based on authentication

Other information

This is actually my first non-trivial work with SolidStart, so I'm sure there are some non-idiomatic things I can improve.

One of the biggest problems I encountered was the inability to create an isomorphic Supabase client. I had a lot of unpredictable behavior until I strictly separated the server and client code. I blame this one line in the docs:

Note that Vinxi HTTP helpers do not treeshake so you can only import them in files that do not contain client or isomorphic code. (https://docs.solidjs.com/solid-start/advanced/request-events#nativeevent)

Since I use Vinxi functions when instantiating a Server Supabase client, the normal isomorphic pattern of isServer ? doServerThing() : doClientThing() didn't work. Maybe dynamic imports are the answer. This is just my theory on why I had to strictly seperate "use client" actions from "use server" actions.

image
image

V1 of the utilities, leaning SolidStart as I go

Register middleware

Actions, Pages, Components

WIP - Struggling with Sessions

Start over

Still in the untested stage

finishing up the initial code

Delete old version

Testing

Improving styles, accepting broken navigation

Pulling out signOut and getUser

Trying things with navigatiotn
Copy link

changeset-bot bot commented Feb 26, 2025

⚠️ No Changeset found

Latest commit: 4a71d20

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for solid-start-landing-page failed. Why did it fail? →

Name Link
🔨 Latest commit 4a71d20
🔍 Latest deploy log https://app.netlify.com/sites/solid-start-landing-page/deploys/67bf8dc6c602f60008194028

@kjrocker kjrocker marked this pull request as ready for review February 26, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant