diff --git a/.gitignore b/.gitignore index cbed8056b..25e502909 100644 --- a/.gitignore +++ b/.gitignore @@ -61,7 +61,7 @@ typings/ .yarn-integrity # dotenv environment variables file -.env +.env.local # Distribution directories dist/ diff --git a/EXAMPLES.md b/EXAMPLES.md index 249f57385..e4d0bc752 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -61,9 +61,9 @@ Check the user's authentication state and log them in or out from the front end import { useUser } from '@auth0/nextjs-auth0'; export default () => { - const { user, loading } = useUser(); + const { user, isLoading } = useUser(); - if (loading) return
Loading login info...
} + {isLoading &&Loading login info...
} - {!loading && !user && ( + {!isLoading && !user && ( <>
To test the login click in Login
diff --git a/examples/basic-example/pages/protected-page.jsx b/examples/basic-example/pages/protected-page.jsx
index 505e36605..1b50251b7 100644
--- a/examples/basic-example/pages/protected-page.jsx
+++ b/examples/basic-example/pages/protected-page.jsx
@@ -4,15 +4,15 @@ import { useUser, withPageAuthRequired } from '@auth0/nextjs-auth0';
import Layout from '../components/layout';
export default function ProtectedPage() {
- const { user, loading } = useUser();
+ const { user, isLoading } = useUser();
return (
Loading profile... Loading profile... Profile:Protected Page
- {loading && {JSON.stringify(user, null, 2)}
diff --git a/examples/kitchen-sink-example/.env.template b/examples/kitchen-sink-example/.env.local.template
similarity index 100%
rename from examples/kitchen-sink-example/.env.template
rename to examples/kitchen-sink-example/.env.local.template
diff --git a/examples/kitchen-sink-example/components/header.tsx b/examples/kitchen-sink-example/components/header.tsx
index 46e4170cf..78e4f2502 100644
--- a/examples/kitchen-sink-example/components/header.tsx
+++ b/examples/kitchen-sink-example/components/header.tsx
@@ -3,7 +3,7 @@ import Link from 'next/link';
import { useUser } from '@auth0/nextjs-auth0';
const Header: React.FunctionComponent = () => {
- const { user, loading } = useUser();
+ const { user, isLoading } = useUser();
return (
Loading login info...
} + {isLoading &&Loading login info...
} - {!loading && !user && ( + {!isLoading && !user && ( <>
To test the login click in Login
diff --git a/examples/kitchen-sink-example/pages/profile.tsx b/examples/kitchen-sink-example/pages/profile.tsx
index 0e045327f..d01966d6f 100644
--- a/examples/kitchen-sink-example/pages/profile.tsx
+++ b/examples/kitchen-sink-example/pages/profile.tsx
@@ -4,15 +4,15 @@ import { useUser, withPageAuthRequired } from '@auth0/nextjs-auth0';
import Layout from '../components/layout';
export default withPageAuthRequired(function Profile(): React.ReactElement {
- const { user, loading } = useUser();
+ const { user, isLoading } = useUser();
return (
Loading profile... Loading profile... Profile:Profile
- {loading && {JSON.stringify(user, null, 2)}
diff --git a/package.json b/package.json
index 670ed8589..e32f042be 100644
--- a/package.json
+++ b/package.json
@@ -17,26 +17,26 @@
},
"scripts": {
"clean": "rimraf dist",
- "pretty": "prettier --write \"src/**/*.ts\" \"src/*.ts\"",
+ "pretty": "prettier --write \"src/**/*.{ts,tsx}\" \"src/*.ts\"",
"lint": "eslint --fix --ext .ts ./src",
- "build": "tsc -p tsconfig.build.json",
- "build:test": "next build tests/fixtures/test-app",
- "build:kitchen-sync": "npm run build --prefix=examples/kitchen-sync-example",
- "build:examples": "npm run build:kitchen-sync",
- "test": "jest tests --coverage --maxWorkers=10",
- "test:watch": "jest --coverage --watch",
- "prepublishOnly": "npm test && npm run lint",
- "prepublish": "npm run build",
"docs": "typedoc --options typedoc.js src",
+ "prepublish": "npm run build",
+ "prepublishOnly": "npm test && npm run lint",
"install:examples": "npm i --prefix=examples/basic-example --no-package-lock && npm i --prefix=examples/kitchen-sink-example --no-package-lock",
+ "build": "tsc -p tsconfig.build.json",
+ "build:test": "next build tests/fixtures/test-app",
+ "build:kitchen-sink": "npm run build --prefix=examples/kitchen-sink-example",
+ "build:examples": "npm run build:kitchen-sink",
+ "build:vercel": "npm run install:examples && npm run build && npm run build:examples",
"start:basic": "npm run dev --prefix=examples/basic-example",
"start:kitchen-sink": "npm run dev --prefix=examples/kitchen-sink-example",
+ "test": "jest tests --coverage --maxWorkers=10",
+ "test:watch": "jest --coverage --watch",
"test:kitchen-sink": "start-server-and-test start:kitchen-sink http-get://localhost:3000 cypress:run",
"test:kitchen-sink:watch": "start-server-and-test start:kitchen-sink 3000 cypress:open",
"test:integration": "npm run test:kitchen-sink",
"cypress:run": "cypress run",
- "cypress:open": "cypress open",
- "build:vercel": "npm run install:examples && npm run build && npm run build:examples"
+ "cypress:open": "cypress open"
},
"repository": {
"type": "git",
diff --git a/src/frontend/use-user.tsx b/src/frontend/use-user.tsx
index b40a3ce81..1d29b7711 100644
--- a/src/frontend/use-user.tsx
+++ b/src/frontend/use-user.tsx
@@ -23,7 +23,7 @@ export interface UserProfile {
*/
export interface UserContext {
user?: UserProfile;
- loading: boolean;
+ isLoading: boolean;
}
/**
@@ -63,7 +63,7 @@ type UserProviderProps = React.PropsWithChildren<{ user?: UserProfile; profileUr
/**
* @ignore
*/
-const User = createContext