1.0.10 • Published 6 years ago

next-key v1.0.10

Weekly downloads
12
License
MIT
Repository
github
Last release
6 years ago

next-key

HOC for Next.js that implements next-key-client

How to use

Install it with npm or yarn

npm install next-key

Create a new instance of the authentication client and create the HOC

// lib/withAuth.js
import { AuthClient } from 'next-key'
// this works too
// import AuthClient from 'next-key'

export const authClient = new AuthClient({ ... })

export default withAuth({
  client: authClient
})

Use the instance on any of your pages!

// pages/index.js
import withAuth from '../lib/withAuth'

export default withAuth(({ accessToken }) => {
  <h1>Hello world!, your accessToken is: {accessToken}<h1>
})

The HOC will take care of refetching the accessToken for you, it will be available in both SSR and client unless you're not logged in, of course

API

AuthClient

Same AuthClient used by next-key-client

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago