1.0.20 • Published 2 years ago
@jeffdude/frontend-helpers v1.0.20
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
- In
package.json
, rename the "homepage" property to something else like "nothomepage". - In
src/index.js
, uncomment the ReactDom.render() codeblock and the imports it uses.
- Here you can configure the
backendURL
.
- Make sure your backend is running, and run
npm start
Deploying
- Iterate version number in
package.json
npm run build
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