Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

With Refresh Authentication

Open in StackBlitz Open in CodeSandbox

This example shows urql in use with @urql/exchange-auth's authExchange to support authentication token and refresh token logic. This largely follows the "Authentication" docs page and uses the trygql.formidable.dev/graphql/web-collections schema.

To run this example install dependencies and run the start script:

yarn install
yarn run start
# or
npm install
npm run start

This example contains:

  • The urql bindings and a React app set up in src/App.jsx
  • Some authentication glue code to store the tokens in src/authStore.js
  • The Client and the authExchange from @urql/exchange-auth set up in src/client.js
  • A basic login form in src/pages/LoginForm.jsx
  • And a basic login guard on src/App.jsx (Note: This isn't using a query in this particular component, since this is just an example)