diff --git a/examples/README.md b/examples/README.md index 9c4c43d..71f2239 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,5 +2,6 @@ ## Follow the steps to run each of the example applications: -- [Create React App](./typescript-app/README.md) -- [Gatsby](./gatsby-app/README.md) +- [Create React App](./typescript-app) +- [Gatsby](./gatsby-app) +- [NextJS](./nextjs-app) diff --git a/examples/gatsby-app/.env.development.sample b/examples/gatsby-app/.env.development.sample new file mode 100644 index 0000000..aa447a8 --- /dev/null +++ b/examples/gatsby-app/.env.development.sample @@ -0,0 +1,2 @@ +GATSBY_LR_APP_NAME= +GATSBY_API_KEY= diff --git a/examples/gatsby-app/.gitignore b/examples/gatsby-app/.gitignore index 09d2f22..a0b8de2 100644 --- a/examples/gatsby-app/.gitignore +++ b/examples/gatsby-app/.gitignore @@ -2,5 +2,11 @@ node_modules/ .cache/ public .history/ -.env.* + .DS_Store + + +# local env files +.env +.env.development +.env.production diff --git a/examples/nextjs-app/.env.local.sample b/examples/nextjs-app/.env.local.sample new file mode 100644 index 0000000..d94dad4 --- /dev/null +++ b/examples/nextjs-app/.env.local.sample @@ -0,0 +1,2 @@ +NEXT_PUBLIC_LR_APP_NAME= +NEXT_PUBLIC_API_KEY= diff --git a/examples/nextjs-app/.eslintrc.json b/examples/nextjs-app/.eslintrc.json new file mode 100644 index 0000000..bffb357 --- /dev/null +++ b/examples/nextjs-app/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "next/core-web-vitals" +} diff --git a/examples/nextjs-app/.gitignore b/examples/nextjs-app/.gitignore new file mode 100644 index 0000000..1437c53 --- /dev/null +++ b/examples/nextjs-app/.gitignore @@ -0,0 +1,34 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel diff --git a/examples/nextjs-app/README.md b/examples/nextjs-app/README.md new file mode 100644 index 0000000..5d2394e --- /dev/null +++ b/examples/nextjs-app/README.md @@ -0,0 +1,12 @@ +## Implementing Authentication using LoginRadius in NextJS application + +## Available Scripts + +```json +"scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "lint": "next lint" +} +``` diff --git a/examples/nextjs-app/layout/Nav.js b/examples/nextjs-app/layout/Nav.js new file mode 100644 index 0000000..75500be --- /dev/null +++ b/examples/nextjs-app/layout/Nav.js @@ -0,0 +1,43 @@ +import { Button, Flex, Stack } from "@chakra-ui/react"; +import { useLRAuth } from "loginradius-react"; + +export default function Nav() { + const { isAuthenticated, user, loginWithRedirect, logout } = useLRAuth(); + + return ( + + + {!user && ( + + )} + {isAuthenticated && user && ( + + )} + + + ); +} diff --git a/examples/nextjs-app/layout/index.js b/examples/nextjs-app/layout/index.js new file mode 100644 index 0000000..1ec4803 --- /dev/null +++ b/examples/nextjs-app/layout/index.js @@ -0,0 +1,11 @@ +import { Box } from "@chakra-ui/react"; +import Nav from "./Nav"; + +export default function Layout({ children }) { + return ( + +