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

refactor: client improvements #1428

Merged
merged 6 commits into from
Mar 5, 2021
Merged

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Mar 3, 2021

What:

Simplify client code, and add TypeScript+JSDoc declarations.

Why:

For better DX. Also, in the process, I have been learning a lot about the choices and implementation. The bundle is also 821 bytes leaner. 🥳

How:

Abstracted away the storage syncing into a handy BroadcastChannel function inspired by https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API (which does not work in Safari, unfortunately 🙁 )

Also removed unnecessary boolean checks in if statements, simplified if blocks, exported all user-facing API other than the export default keyword. (In local development, imports from "next-auth/client" did not work for some reason. Might be something with the dev app setup)

the concept of clientId was not necessary, since storage events already only listen to other window contexts. See https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

#844, #1084

@vercel
Copy link

vercel bot commented Mar 3, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/Canyc4LxsgLorV3dT2gvYwC2LN5f
✅ Preview: https://next-auth-git-features-client-improvements-nextauthjs.vercel.app

@github-actions github-actions bot added client Client related code core Refers to `@auth/core` labels Mar 3, 2021
@vercel vercel bot temporarily deployed to Preview March 3, 2021 23:24 Inactive
@vercel vercel bot temporarily deployed to Preview March 3, 2021 23:42 Inactive
@vercel vercel bot temporarily deployed to Preview March 4, 2021 01:30 Inactive
@balazsorban44 balazsorban44 marked this pull request as ready for review March 5, 2021 21:31
@balazsorban44 balazsorban44 merged commit 3aee24b into main Mar 5, 2021
@balazsorban44 balazsorban44 deleted the features/client-improvements branch March 5, 2021 21:47
@github-actions
Copy link

github-actions bot commented Mar 5, 2021

🎉 This PR is included in version 3.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 4.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

mnphpexpert added a commit to mnphpexpert/next-auth that referenced this pull request Sep 2, 2024
* docs(client): add TS definitions to client

* docs(client): add documentation links to public methods

* refactor(client): simplify window sync, simplify logic

* refactor(client): extract repeating logic to _fetchData

* refactor(client): remove clientId

* refactor(client): use session in Provider if passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related code core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant