Nhost React Typescript Example App
Nhost example app in React (Typescript) using Hasura.
Technologies
- โจNhost
- โก React
- ๐กTypeScript
- ๐ Tailwind
Get started
- Create a project on Nhost.
- Clone this repo:
git clone [email protected]:nhost/nhost-react-typescript-example-app.git
. - Copy
config-example.yaml
toconfig.yaml
inhasura/
. - In
hasura/config.yaml
, updateendpoint
andadmin_secret
from your Nhost project. - Apply migrations and metadata in the
hasura/
-folder:hasura migrate apply; hasura metadata apply;
. Make sure you have the Hasura CLI installed. - In
src/utils
, copyconfig-example.ts
toconfig.ts
. - Update
config.ts
withBACKEND_ENDPOINT
andGRAPHQL_ENDPOINT
from your project at Nhost. yarn install
.yarn start
.
What's in the example app?
Auth (JWT)
- Register (email/password)
- Register using a OAuth provider (Google, Github etc)
- Login
- Handle refresh token (automatically)
Data (GraphQL)
- Create todo
- Read todo
- Update todo
- Delete todo
Storage (S3)
- Upload file
- Read file
- Delete file
Apollo GrahpQL Codegen and Autocomplete
Edit apollo.config.js
and package.json
(apollo:generate
). The only thing you need to edit is endpoint
and header
(x-hasura-admin-secret
).
Once the two files are correctly configured you can auto generate type definitions from GraphQL using:
yarn apollo:codegen
All type definitions will be placed in src/generated/
.