Skip to content

Commit 6cceff5

Browse files
authored
docs: change official name from useSession to useAuth in docs, keep disclaimers (#325)
1 parent 94532cc commit 6cceff5

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

docs/content/1.getting-started/1.index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ Here's the source-code https://github.com/sidebase/nuxt-auth-example of the exam
5555

5656
## Application Side Session Management
5757
::alert{type="info"}
58-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
58+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
5959
::
6060
::list{type="success"}
61-
- composable `const { signIn, signOut, status, data, lastRefreshedAt, ... } = useSession()`
61+
- composable `const { signIn, signOut, status, data, lastRefreshedAt, ... } = useAuth()`
6262
- Auto-refresh the session periodically
6363
- Auto-refresh the session on tab-refocus
6464
- Efficient session fetching: One time on page load, afterwards for specific actions (e.g., on navigation)

docs/content/1.getting-started/3.quick-start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export default NuxtAuthHandler({
2929
That's it! You can now use all user-related functionality, for example:
3030

3131
::alert{type="info"}
32-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
32+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
3333
::
3434
::code-group
3535
```ts [Application side]
3636
// file: e.g ~/pages/login.vue
37-
const { status, data, signIn, signOut } = useSession()
37+
const { status, data, signIn, signOut } = useAuth()
3838

3939
status.value // Session status: `unauthenticated`, `loading`, `authenticated`
4040
data.value // Session data, e.g., expiration, user.email, ...

docs/content/3.application-side/1.index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ description: "Application-side usage of `nuxt-auth` for Vue / Nuxt 3 apps."
66

77
On the application-side this module offers:
88
::list{type="success"}
9-
- [`useSession` composable for session access and management](/nuxt-auth/application-side/session-access-and-management)
9+
- [`useAuth` composable for session access and management](/nuxt-auth/application-side/session-access-and-management)
1010
::alert{type="info"}
11-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
11+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
1212
::
1313
- [Creation of custom sign-in pages](/nuxt-auth/application-side/custom-sign-in-page)
1414
- [Middleware to protect your application on the application side](/nuxt-auth/application-side/protecting-pages)

docs/content/3.application-side/2.session-access-and-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Session Access and Management
22
::alert{type="info"}
3-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
3+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
44
::
55

6-
The `useSession` composable is your main gateway to accessing and manipulating session-state and data. Here's the main methods you can use:
6+
The `useAuth` composable is your main gateway to accessing and manipulating session-state and data. Here's the main methods you can use:
77

88
```ts
99
const {
@@ -15,7 +15,7 @@ const {
1515
getSession,
1616
signIn,
1717
signOut,
18-
} = useSession()
18+
} = useAuth()
1919

2020
// Session status, either `unauthenticated`, `loading`, `authenticated`, see https://next-auth.js.org/getting-started/client#signout
2121
status.value

docs/content/3.application-side/3.custom-sign-in-page.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To create a custom sign-in page you will need to:
99

1010
To create your custom sign-in page you can use `signIn` to directly start a provider-flow once the user selected it, e.g., by clicking on a button on your custom sign-in page. Here is a very simple sign-in page that either directly starts a github-oauth sign-in flow or directly signs in the user via the credentials flow:
1111
::alert{type="info"}
12-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
12+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
1313
::
1414
```vue
1515
<!-- file: ~/pages/login.vue -->
@@ -30,7 +30,7 @@ definePageMeta({
3030
}
3131
})
3232
33-
const { signIn } = useSession()
33+
const { signIn } = useAuth()
3434
</script>
3535
```
3636

@@ -89,10 +89,10 @@ Above we use the [guest mode](/nuxt-auth/application-side/guest-mode). This opti
8989

9090
You can handle sign-in errors yourself by calling `signIn` with `redirect: false` and inspecting its result for errors. For example:
9191
::alert{type="info"}
92-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
92+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
9393
::
9494
```ts
95-
const { signIn } = useSession()
95+
const { signIn } = useAuth()
9696

9797
const mySignInHandler = async ({ username, password }: { username: string, password: string }) => {
9898
const { error, url } = await signIn('credentials', { username, password, redirect: false })

docs/content/3.application-side/4.protecting-pages.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Creating a custom middleware is an advanced, experimental option and may result
8888

8989
To implement your custom middleware:
9090
1. Create an application-side middleware that applies either globally or is named (see [the Nuxt docs for more](https://nuxt.com/docs/guide/directory-structure/middleware#middleware-directory))
91-
2. Add logic based on `useSession` to it
91+
2. Add logic based on `useAuth` to it
9292

9393
When adding the logic, you need to watch out when calling other `async` composable functions. This can lead to `context`-problems in Nuxt, see [the explanation for this here](https://github.com/nuxt/framework/issues/5740#issuecomment-1229197529). In order to avoid these problems, you will need to either:
9494
- use the undocumented `callWithNuxt` utility when `await`ing other composables,
@@ -99,7 +99,7 @@ Following are examples of both kinds of usage:
9999
```ts [direct return]
100100
// file: ~/middleware/authentication.global.ts
101101
export default defineNuxtRouteMiddleware((to) => {
102-
const { status, signIn } = useSession()
102+
const { status, signIn } = useAuth()
103103

104104
// Return immeadiatly if user is already authenticated
105105
if (status.value === 'authenticated') {
@@ -122,7 +122,7 @@ export default defineNuxtRouteMiddleware((to) => {
122122
// It's important to do this as early as possible
123123
const nuxtApp = useNuxtApp()
124124

125-
const { status, signIn } = useSession()
125+
const { status, signIn } = useAuth()
126126

127127
// Return immeadiatly if user is already authenticated
128128
if (status.value === 'authenticated') {
@@ -139,7 +139,7 @@ export default defineNuxtRouteMiddleware((to) => {
139139
```
140140
::
141141
::alert{type="info"}
142-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
142+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
143143
::
144144

145145
## Guest Mode

docs/content/4.server-side/4.rest-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ All endpoints that NextAuth.js supports are also supported by `nuxt-auth`:
1414

1515
The `basePath` is `/api/auth` per default and [can be configured in the `nuxt.config.ts`](/nuxt-auth/configuration/nuxt-config).
1616

17-
You can directly interact with these API endpoints if you wish to, it's probably a better idea to use `useSession` where possible though. [See the full rest API documentation of NextAuth.js here](https://next-auth.js.org/getting-started/rest-api).
17+
You can directly interact with these API endpoints if you wish to, it's probably a better idea to use `useAuth` where possible though. [See the full rest API documentation of NextAuth.js here](https://next-auth.js.org/getting-started/rest-api).
1818
::alert{type="info"}
19-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
19+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
2020
::

docs/content/5.recipes/4.custom-session-data.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ Notice that in the `jwt` callback we pass both the `access_token` and the `role`
8888
After that you can access the new fields in the data portion of the session object:
8989
9090
::alert{type="info"}
91-
In v0.5.0 of nuxt-auth `useSession()` will be renamed to `useAuth()`.
91+
Prior to v0.5.0 `useAuth()` was called `useSession()`.
9292
::
9393
```ts
94-
const { status, data } = useSession();
94+
const { status, data } = useAuth();
9595

9696
console.log(data);
9797

docs/content/6.resources/4.prior-work.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ In our investigation we found prior attempts to make NextAuth.js framework agnos
1414
- [NextAuth.js app examples](https://github.com/nextauthjs/next-auth/tree/main/apps)
1515
- [Various comments, proposals, ... of this thread](https://github.com/nextauthjs/next-auth/discussions/3942), special thanks to @brillout for starting the discussion, @balazsorban44 for NextAuth.js and encouraging the discussion, @wobsoriano for adding PoCs for multiple languages
1616

17-
The main part of the work was to piece everything together, resolve some outstanding issues with existing PoCs, add new things where nothing existed yet, e.g., for the `useSession` composable by going through the NextAuth.js client code and translating it to a Nuxt 3 approach.
17+
The main part of the work was to piece everything together, resolve some outstanding issues with existing PoCs, add new things where nothing existed yet, e.g., for the `useAuth` composable by going through the NextAuth.js client code and translating it to a Nuxt 3 approach.
1818

19-
The module had another big iteration in collaboration with @JoaoPedroAS51 to make `useSession` a sync operation and trigger the session lifecycle from a plugin rather than the `useSession` composable itself.
19+
The module had another big iteration in collaboration with @JoaoPedroAS51 to make `useAuth` a sync operation and trigger the session lifecycle from a plugin rather than the `useAuth` composable itself.

0 commit comments

Comments
 (0)