Skip to content

feat(solidstart): createSession hook & hydration fixes #7331

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

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

Conversation

OrJDev
Copy link
Contributor

@OrJDev OrJDev commented Apr 21, 2023

then you can use the createSession hook:

import { createSession } from "@auth/solid-start/client"
const session = createSession()

const user = () => session()?.user

This will return a resource, in Solid a resource can be used to trigger suspense so this could be used like:

import { Show, type VoidComponent } from "solid-js"
import { A } from "solid-start"
import { createSession, signIn, signOut } from "~/auth/client"

const AuthShowcase: VoidComponent = () => {
  const session = createSession()
  return (
    <div class="flex flex-col items-center justify-center gap-4">
      <Show
        when={session()}
        fallback={
          <button
            onClick={() => signIn("discord", { redirectTo: "/" })}
            class="rounded-full bg-white/10 px-10 py-3 font-semibold text-white no-underline transition hover:bg-white/20"
          >
            Sign in
          </button>
        }
      >
        <span class="text-xl text-white">Welcome {session()?.user?.name}</span>
        <button
          onClick={() => signOut({ redirectTo: "/" })}
          class="rounded-full bg-white/10 px-10 py-3 font-semibold text-white no-underline transition hover:bg-white/20"
        >
          Sign out
        </button>
      </Show>
    </div>
  )
}

This also triggers suspense so the page will not be loaded until the session was passed.

@vercel
Copy link

vercel bot commented Apr 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2023 9:33am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Apr 22, 2023 9:33am

@vercel
Copy link

vercel bot commented Apr 21, 2023

@OrJDev is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

@OrJDev
Copy link
Contributor Author

OrJDev commented Apr 21, 2023

failing test has nothing to do with my changes

@socket-security
Copy link

New dependency changes detected. Learn more about Socket for GitHub ↗︎


👍 No new dependency issues detected in pull request

Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore [email protected] bar@* or ignore all packages with @SocketSecurity ignore-all

Pull request alert summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues

📊 Modified Dependency Overview:

➕ Added Package Capability Access +/- Transitive Count Publisher
[email protected] None +0 lukastaegert

@balazsorban44 balazsorban44 force-pushed the main branch 2 times, most recently from fa96b45 to 65aa467 Compare October 24, 2023 00:35
@ndom91 ndom91 changed the title feat: createSession hook for SolidStart & Hydration Fixes feat(solidstart): createSession hook & hydration fixes Apr 8, 2024
Copy link

stale bot commented Jan 31, 2025

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

@stale stale bot added the stale Did not receive any activity for 60 days label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frameworks solidjs stale Did not receive any activity for 60 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants