1.0.20 • Published 2 years ago

@jeffdude/frontend-helpers v1.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

FrontendHelpers

Authentication state handling & various other frontend helpers I share between my projects.

Authentication + Querying functionality for my bespoke backend framework here.

Getting Started

npm install --save @jeffdude/frontend-helpers
# or
yarn install @jeffdude/frontend-helpers

Authentication State Handling

A HOC provides all auth state data. index.js:

import { JFHApp } from '@jeffdude/frontend-helpers'

ReactDOM.render(
  <React.StrictMode>
    <JFHApp config={{backendURL: "http://192.168.0.88:3600"}}>
      <App />
    </JFHApp>
  </React.StrictMode>,
  document.getElementById('root')
);

Log In:

import { useLogin } from '@jeffdude/frontend-helpers'

function MyComponent() {
  const login = useLogin()
  return (
    <form onSubmit={() => login({email, password})}>
      ...
    </form>
  )
}

Authenticated Backend Query:

import { useGetQuery } from '@jeffdude/frontend-helpers'

const myQuery = useGetQuery(endpoint, key, { version = "v1", ...options });

Authenticated Backend Mutation:

import { useCreateMutation } from '@jeffdude/frontend-helpers'

function useMyMutation(){
  return useCreateMutation(
    {endpoint, method, headers = {}, verb, body = true, options, createMutationCallOptions}
  )
}

Using The Debug Site

  1. In package.json, rename the "homepage" property to something else like "nothomepage".
  2. In src/index.js, uncomment the ReactDom.render() codeblock and the imports it uses.
  • Here you can configure the backendURL.
  1. Make sure your backend is running, and run npm start

Deploying

  1. Iterate version number in package.json
  2. npm run build
  3. npm login && npm publish
1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.20

2 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago