Compare commits

...

430 Commits

Author SHA1 Message Date
Pilou
d8d1423158 Merge pull request #577 from nhost/changeset-release/main
chore: update versions
2022-05-19 13:42:24 +02:00
github-actions[bot]
e95881089b chore: update versions 2022-05-19 10:04:56 +00:00
Szilárd Dóró
8726458df9 Merge pull request #572 from nhost/chore/auth-test-coverage
chore: Auth test coverage
2022-05-19 12:04:04 +02:00
Szilárd Dóró
6c4233948d added patch notes 2022-05-19 10:49:44 +02:00
Szilárd Dóró
160ebd9f04 Merge pull request #562 from nhost/changeset-release/main
chore: update versions
2022-05-19 10:22:16 +02:00
Szilárd Dóró
c16f630a7b Added refreshIntervalTime related tests 2022-05-19 10:05:03 +02:00
Johan Eliasson
688471faf0 Merge pull request #571 from nhost/fix/docs-typo
fix: Typo in docs
2022-05-19 09:27:52 +02:00
github-actions[bot]
f07d17a3e8 chore: update versions 2022-05-19 06:49:42 +00:00
Pilou
609681e741 Merge pull request #566 from nhost/fix/redirect-query-parameters
accept query parameters from both relative `redirectTo` URLs and the client URL
2022-05-19 08:48:44 +02:00
Szilárd Dóró
ab8d20a354 fix: Typo in docs 2022-05-19 08:24:01 +02:00
Johan Eliasson
543c85c85e Merge pull request #570 from nhost/docs-serverless-functions-underscore
docs: added information about prepending underscore
2022-05-18 21:30:43 +02:00
Johan Eliasson
4a9fbd6d84 using the word underscore 2022-05-18 21:29:40 +02:00
Johan Eliasson
24d45a1aed rephrase 2022-05-18 21:28:15 +02:00
Johan Eliasson
4511b7b538 added information about prepending underscore 2022-05-18 21:25:00 +02:00
Johan Eliasson
cb39f3d9ab Merge pull request #564 from nhost/docs-yu8g79yjo
Docs: CLI
2022-05-18 21:21:29 +02:00
Johan Eliasson
d49beb72bc typo 2022-05-18 21:14:19 +02:00
Johan Eliasson
d5ca9ae2c5 commands in sidebar 2022-05-18 21:09:53 +02:00
Johan Eliasson
80eeea49be moved storage and serverless functions to it's own files only instead of in directory 2022-05-18 17:54:29 +02:00
Johan Eliasson
e92716097e added list and upgrade 2022-05-18 17:44:03 +02:00
Johan Eliasson
54e11430b9 use up and down instad of dev and purge for docs 2022-05-18 17:42:48 +02:00
Johan Eliasson
7af47ba7d2 update 2022-05-18 17:41:27 +02:00
Johan Eliasson
7b624eae1c Updated CLI reference docs 2022-05-18 17:39:01 +02:00
Pierre-Louis Mercereau
151871cedc refactor: unnest if statement 2022-05-18 16:38:20 +02:00
Szilárd Dóró
4ecde10b99 Simplified time based token refresh tests
Also removed unnecessary error checks from auth machine
2022-05-18 15:49:26 +02:00
Szilárd Dóró
0530bac1f1 Token auto-refresh tests
- Added token auto-refresh related tests
- Simplified test context initialization
2022-05-18 15:02:02 +02:00
Pierre-Louis Mercereau
13e4fa73d5 typo 2022-05-18 12:21:13 +02:00
Pierre-Louis Mercereau
0b58894ef1 fix: accept query parameters from both relative redirectTo URLs and the client URL 2022-05-18 11:27:22 +02:00
Johan Eliasson
3ba123dbff updated platform CLI docs 2022-05-18 10:44:15 +02:00
Johan Eliasson
0ffdeab89f updated docusaurus packages 2022-05-18 09:33:10 +02:00
Szilárd Dóró
df02e25d02 Merge pull request #561 from nhost/chore/auth-tests
chore: Authentication related tests
2022-05-17 20:18:34 +02:00
Szilárd Dóró
c7a407f111 added changesets 2022-05-17 15:53:43 +02:00
Szilárd Dóró
91edc67a5e Added password change related tests 2022-05-17 15:44:21 +02:00
Szilárd Dóró
d1a7bd7f94 Added email change tests 2022-05-17 15:31:47 +02:00
Johan Eliasson
31b0830b91 Merge pull request #558 from nhost/sdk-docs-uygsa9h8dio
Docs: Updated inline and SDK docs
2022-05-17 14:36:19 +02:00
Szilárd Dóró
7c39b14fd2 Added MFA generation / activation tests 2022-05-17 14:19:24 +02:00
Johan Eliasson
16669d98e4 edit links correct for storage 2022-05-17 13:21:51 +02:00
Johan Eliasson
0696c108eb typo 2022-05-17 13:18:12 +02:00
Johan Eliasson
88f8e5dbed small updates 2022-05-17 13:17:08 +02:00
Pilou
5a288f52df Merge pull request #560 from nhost/contributors-readme-action-Zl7cUfYzsW
contributors readme action update
2022-05-17 12:51:36 +02:00
github-actions[bot]
f922c02c08 contrib-readme-action has updated readme 2022-05-17 10:48:49 +00:00
Pilou
1abb4354e8 Merge pull request #549 from gaurav1999/patch-1
user-management: Specify metadata info
2022-05-17 12:48:35 +02:00
Johan Eliasson
b3f68b8748 more docs update 2022-05-17 12:11:28 +02:00
Johan Eliasson
0ee2171754 single user 2022-05-17 11:48:04 +02:00
Johan Eliasson
a112a9a8ad link fixed 2022-05-17 11:21:23 +02:00
Szilárd Dóró
195b8ee4b7 Added email verification related tests
- improved the way validations are tested
- added email validation guard to reset password machine
2022-05-17 10:53:19 +02:00
Johan Eliasson
21a9da792f storage inline docs updated 2022-05-17 10:37:34 +02:00
Johan Eliasson
fd562b9c78 updated auth sdk docs 2022-05-17 10:20:01 +02:00
Szilárd Dóró
eca4ed92c1 Added password reset related tests 2022-05-17 10:17:48 +02:00
Szilárd Dóró
adf4d2b997 vitest bump, remaining token related tests 2022-05-17 09:52:12 +02:00
Johan Eliasson
3a724f847d Merge branch 'main' into sdk-docs-uygsa9h8dio 2022-05-17 09:47:42 +02:00
Johan Eliasson
99f941b060 next and react cleanup 2022-05-17 09:45:35 +02:00
Johan Eliasson
97392e547f all react hooks done first draft 2022-05-17 09:11:15 +02:00
Johan Eliasson
685e2dfccc react inline docs 2022-05-16 22:54:31 +02:00
Szilárd Dóró
0222d0fa22 improved refresh token related tests 2022-05-16 17:21:04 +02:00
Johan Eliasson
08e7a8e23a link fixed 2022-05-16 16:19:35 +02:00
Johan Eliasson
24faf32abe react docs update 2022-05-16 16:11:16 +02:00
Szilárd Dóró
8662674abe auto sign-in tests, improved in-memory storage 2022-05-16 16:05:55 +02:00
Johan Eliasson
e9a01588da JavaScript index update 2022-05-16 14:15:59 +02:00
Johan Eliasson
17e370e889 update 2022-05-16 14:00:25 +02:00
Johan Eliasson
5929da369f more inline docs 2022-05-16 13:59:22 +02:00
Johan Eliasson
d4450ea0e4 added nhost.auth 2022-05-16 13:44:37 +02:00
Johan Eliasson
f5b86f5865 storage inline docs updated 2022-05-16 13:43:59 +02:00
Szilárd Dóró
a6cfdb67d0 Merge pull request #557 from nhost/testing-framework
Testing framework
2022-05-16 13:23:34 +02:00
Johan Eliasson
645eaf6367 updated hasura auth js docs 2022-05-16 13:22:53 +02:00
Szilárd Dóró
5217ffa5e3 renamed test files, removed unnecessary states 2022-05-16 12:36:42 +02:00
Szilárd Dóró
b08790b7ab removed "sleep" calls from sign out tests 2022-05-16 11:48:24 +02:00
Szilárd Dóró
5802feedec code format improvements, fixed sign out tests 2022-05-16 11:23:16 +02:00
Johan Eliasson
79f153e627 Merge pull request #556 from nhost/functions-f657g8hui
docs: Serverless functions
2022-05-16 09:22:31 +02:00
Johan Eliasson
84c5ae1cba update 2022-05-16 09:22:20 +02:00
Johan Eliasson
b5f82d9dd0 Merge pull request #554 from nhost/nunopato-patch-1
Remove outdated mention to minio.
2022-05-16 09:13:07 +02:00
Johan Eliasson
00e03d44b5 more info 2022-05-16 09:08:11 +02:00
Johan Eliasson
15aacc09db production info 2022-05-16 09:04:26 +02:00
Johan Eliasson
01b53348c4 updates 2022-05-16 08:54:59 +02:00
Johan Eliasson
aa770cc15a serverless functions 2022-05-16 08:32:51 +02:00
Nuno Pato
552790fe3f Remove outdated mention to minio. 2022-05-13 17:24:12 +02:00
Szilárd Dóró
4d08a2c1dd Merge pull request #552 from nhost/contributors-readme-action-VJJueJLfwd
contributors readme action update
2022-05-13 15:05:36 +02:00
github-actions[bot]
ee34b9d2aa contrib-readme-action has updated readme 2022-05-13 12:29:06 +00:00
Johan Eliasson
0d87c30a8e Merge pull request #517 from nhost/docs-guides
Docs guides
2022-05-13 14:28:50 +02:00
Johan Eliasson
d7aaeeb8cc syncing package manager tabs 2022-05-13 14:20:28 +02:00
Johan Eliasson
101f4f502d v12 latest 2022-05-13 14:17:15 +02:00
Johan Eliasson
d070680abd settings only work locally for now 2022-05-13 14:16:17 +02:00
Szilárd Dóró
aa16ba979b Sign out related tests
- added sign out related tests
- still need to figure out token removal from storage
2022-05-13 14:02:42 +02:00
Szilárd Dóró
3f07c33b17 improved Sign In test structure in Core package 2022-05-13 10:49:37 +02:00
Szilárd Dóró
f935269a6b improved Sign In tests, created Sign Up tests 2022-05-13 09:55:59 +02:00
Szilárd Dóró
965f1b26b0 Merge branch 'main' into testing-framework 2022-05-12 16:44:22 +02:00
Szilárd Dóró
08394ffd01 Sign up test stubs, Sign in test wording updates 2022-05-12 16:28:23 +02:00
Szilárd Dóró
802d095044 added remaining password sign in tests 2022-05-12 16:09:53 +02:00
Szilárd Dóró
9340e115d1 final MFA TOTP tests 2022-05-12 14:58:25 +02:00
Szilárd Dóró
170dbfc930 MFA ticket validation, MFA TOTP tests 2022-05-12 14:43:05 +02:00
Szilárd Dóró
e44c4b2e93 Passwordless SMS OTP tests 2022-05-12 11:32:59 +02:00
Szilárd Dóró
5154d31126 Passwordless SMS tests, MSW folder structure 2022-05-12 10:32:11 +02:00
Johan Eliasson
f5e542e4c1 updated template link 2022-05-12 09:21:47 +02:00
Johan Eliasson
029925d88f added graphql dependency 2022-05-12 08:12:52 +02:00
Gaurav Agrawal
718a4db33c user-management: Specify metadata info
fixes #241
2022-05-11 21:16:35 +05:30
Szilárd Dóró
5a7be0cfd4 Passwordless email tests, hasura-auth-js CI fix 2022-05-11 16:18:32 +02:00
Johan Eliasson
f4dc867242 updated CTA 2022-05-11 15:58:19 +02:00
Johan Eliasson
038e279660 typo 2022-05-11 15:05:22 +02:00
Johan Eliasson
f671a5a420 small updates 2022-05-11 15:03:59 +02:00
Johan Eliasson
95dbfd59ee Merge pull request #535 from gdangelo/patch-5
docs: Update Next.js quickstart guide
2022-05-11 14:30:33 +02:00
Johan Eliasson
8980c99200 Merge pull request #536 from gdangelo/patch-6
docs: Update React quickstart guide
2022-05-11 14:20:35 +02:00
Szilárd Dóró
c0dcdb2410 started working on passwordless sign in tests 2022-05-11 14:20:07 +02:00
Pilou
1035639850 Merge pull request #544 from nhost/changeset-release/main
chore: update versions
2022-05-11 13:33:54 +02:00
Szilárd Dóró
9be836b036 Merge branch 'main' into testing-framework 2022-05-11 13:15:45 +02:00
github-actions[bot]
0e96e7329e chore: update versions 2022-05-11 11:13:25 +00:00
Szilárd Dóró
19ccc5ab0d Merge pull request #548 from nhost/axios-version-bump
Bump `axios` and set correct `Content-Type` for file upload
2022-05-11 13:12:16 +02:00
Szilárd Dóró
e094e682ce bump axios and fix file upload Content-Type
chore: bump axios from 0.26.0 to 0.27.2
fix: add Content-Type to file upload request headers
2022-05-11 12:45:52 +02:00
Szilárd Dóró
49cc3cb41b added test case for network errors when signing in 2022-05-11 10:23:16 +02:00
Szilárd Dóró
e0d81d419f fix: idempotent test results if the order of tests changes 2022-05-11 09:21:59 +02:00
Pilou
74eb71f8f0 Merge pull request #543 from nhost/fix/signup-states
Fix/signup states
2022-05-11 08:59:41 +02:00
Pierre-Louis Mercereau
a931c15073 Merge main and fix wrong negation 2022-05-11 08:30:40 +02:00
Szilárd Dóró
e04d88b034 chore: improved test helper structure 2022-05-10 18:56:22 +02:00
Szilárd Dóró
eca552b931 merged email and password error test cases 2022-05-10 17:30:33 +02:00
Szilárd Dóró
ed30bdd7e1 chore: improved structure of helpers 2022-05-10 17:26:49 +02:00
Szilárd Dóró
b76bc30fe4 Merge pull request #546 from nhost/testing-framework-patch
refactor: reset errors when entering auth states instead of doing it when exiting the signOut state
2022-05-10 16:54:00 +02:00
Pierre-Louis Mercereau
2b571ebf23 refactor: reset errors when entering auth states instead of doing it when exiting the signOut state 2022-05-10 16:41:45 +02:00
Szilárd Dóró
ebe9fb0a44 started working on Sign In flow related tests 2022-05-10 13:49:37 +02:00
Pilou
9ae5e485e6 Merge pull request #520 from nhost/feat/improve-errors
Improve the handling of authentication errors
2022-05-10 10:39:57 +02:00
Pierre-Louis Mercereau
2965a7bf5b chore: update lockfile 2022-05-10 10:12:52 +02:00
Pierre-Louis Mercereau
236ce72bb3 fix: correct email verification states and useSignUpEmailPassword loading state 2022-05-10 10:12:03 +02:00
Pierre-Louis Mercereau
5ad5832e41 docs: minor improvements in the examples 2022-05-10 10:08:54 +02:00
Szilárd Dóró
a57825e5ad Merge branch 'main' into testing-framework 2022-05-10 09:45:20 +02:00
Pilou
1e233b6582 Merge pull request #541 from nhost/changeset-release/main
chore: update versions
2022-05-09 21:47:15 +02:00
github-actions[bot]
9ebd014287 chore: update versions 2022-05-09 19:32:16 +00:00
Pilou
6ce2534a36 Merge pull request #540 from nhost/dont-ignore-changeset
ci: trigger GH action even if comitted files are only in the `.changeset` directory
2022-05-09 21:31:23 +02:00
Pierre-Louis Mercereau
9f8e792f0d ci: trigger GH action even if comitted files are only in the .changeset directory 2022-05-09 21:29:29 +02:00
Pierre-Louis Mercereau
e1383106d9 Merge remote-tracking branch 'origin/main' into feat/improve-errors 2022-05-09 21:16:33 +02:00
Szilárd Dóró
812d7a8eae Merge pull request #539 from nhost/chore/nhost-react-changesets
chore: @nhost/react release notes
2022-05-09 21:10:53 +02:00
Szilárd Dóró
2887ce0f82 @nhost/react release notes 2022-05-09 21:08:18 +02:00
Szilárd Dóró
8bdfb8fcac Merge pull request #538 from nhost/fix/xstate-react-version
fix: @xstate/react bump to support React 18
2022-05-09 21:00:54 +02:00
Szilárd Dóró
573436dd87 fix: @xstate/react version to support React 18 2022-05-09 20:48:47 +02:00
Grégory D'Angelo
c7ce66597a docs: Update React quickstart guide
Update the guide based on Johan's feedback + add a new section at the end to show how to use the GraphQL API to fetch user data + reflect changes from the provided template.
2022-05-09 19:16:08 +02:00
Grégory D'Angelo
c82605c4e8 docs: Update Next.js quickstart guide 2022-05-09 19:12:41 +02:00
Szilárd Dóró
ef41ce8bb2 merged Vite configs, watch mode 2022-05-09 15:15:17 +02:00
Szilárd Dóró
864074fba5 added support for vitest
- Upgraded tests to use utilities of vitest
2022-05-09 14:52:32 +02:00
Szilárd Dóró
f58c2bb9ce Merge pull request #530 from nhost/changeset-release/main
chore: update versions
2022-05-09 14:10:10 +02:00
Pierre-Louis Mercereau
4eac3101c9 refactor: deprecated the use of isError when it is the negation of isSuccess 2022-05-09 13:01:54 +02:00
Pierre-Louis Mercereau
80bd938336 Merge remote-tracking branch 'origin/main' into feat/improve-errors 2022-05-09 10:50:43 +02:00
Pilou
41db6f613a Merge pull request #532 from nhost/contributors-readme-action-dGXEs_q2EP
contributors readme action update
2022-05-09 10:44:31 +02:00
github-actions[bot]
ee84bfa098 chore: update versions 2022-05-09 08:43:56 +00:00
github-actions[bot]
ad1b7b80e2 contrib-readme-action has updated readme 2022-05-09 08:42:51 +00:00
Pilou
3fcd345cff Merge pull request #528 from nhost/nextjs-example-email-sent-model
nextjs example: add an "email sent" modal to the magic-link page
2022-05-09 10:42:37 +02:00
Pierre-Louis Mercereau
43a3f1dd46 Merge remote-tracking branch 'origin/main' into nextjs-example-email-sent-model 2022-05-09 10:36:36 +02:00
Pilou
3ec745c91e Merge pull request #514 from MarcelloTheArcane/patch-1
Fix signIn/signUp typo
2022-05-09 10:34:09 +02:00
Pierre-Louis Mercereau
92deec4531 docs: docgen 2022-05-09 10:28:26 +02:00
Pierre-Louis Mercereau
c7fcc9fe82 Merge remote-tracking branch 'origin/main' into patch-1 2022-05-09 10:27:22 +02:00
Pilou
081377af6c Merge pull request #531 from nhost/clean-nextjs-example
refactor: stop using next-transpile-modules
2022-05-09 10:25:11 +02:00
Pierre-Louis Mercereau
23cb207afc style: typo 2022-05-09 10:23:59 +02:00
Johan Eliasson
62b1495a22 docs update 2022-05-09 10:13:16 +02:00
Pierre-Louis Mercereau
8a79a7102f Merge remote-tracking branch 'origin/main' into feat/improve-errors 2022-05-09 10:11:40 +02:00
Pierre-Louis Mercereau
0f55f6db9b style: post feedback 2022-05-09 10:07:04 +02:00
Pierre-Louis Mercereau
7b16a8d790 Merge remote-tracking branch 'origin/main' into nextjs-example-email-sent-model 2022-05-09 10:05:00 +02:00
Pierre-Louis Mercereau
dca8233601 refactor: stop using next-transpile-modules
It is not required in the new monorepo setup
2022-05-09 10:03:27 +02:00
Pilou
a7535b260b Merge pull request #529 from nhost/contributors-readme-action-xXIDbIv_3L
contributors readme action update
2022-05-09 09:56:40 +02:00
github-actions[bot]
82520963f1 contrib-readme-action has updated readme 2022-05-09 07:48:43 +00:00
Szilárd Dóró
722abd9a19 Merge pull request #462 from nhost/monorepo-improvements
Monorepo improvements
2022-05-09 09:48:28 +02:00
Szilárd Dóró
2aff6c0b4e fix: lock file changes 2022-05-09 09:12:03 +02:00
Szilárd Dóró
e101915f60 Merge branch 'main' into monorepo-improvements 2022-05-09 09:09:35 +02:00
Pierre-Louis Mercereau
0195143fe1 fix: correct the way to monitor the email is awaiting verification 2022-05-08 19:08:53 +02:00
Pierre-Louis Mercereau
e362925041 feat: pull needsEmailVerification out of the signedIn state 2022-05-07 21:19:26 +02:00
Pierre-Louis Mercereau
b4f8c7457d docs: remove option that raises a React warning 2022-05-07 16:39:59 +02:00
Pierre-Louis Mercereau
84f1ab2f61 docs: add an "email sent" modal to the magic-link page 2022-05-07 16:35:41 +02:00
Pilou
dee93bb873 Merge pull request #526 from nhost/changeset-release/main
chore: update versions
2022-05-06 22:29:55 +02:00
github-actions[bot]
173b587802 chore: update versions 2022-05-06 20:24:16 +00:00
Pilou
30ef1660b4 Merge pull request #525 from nhost/fix/cookie-mode
fix: correct cookie storage type
2022-05-06 22:23:12 +02:00
Pierre-Louis Mercereau
a613aa9f0c refactor: unnest if block 2022-05-06 22:12:50 +02:00
Pierre-Louis Mercereau
3c03b9b46f refactor: remove dead code 2022-05-06 22:09:51 +02:00
Pierre-Louis Mercereau
65a3061146 fix: correct cookie storage type 2022-05-06 22:01:38 +02:00
Johan Eliasson
f4c2088bce grammarly updates 2022-05-06 20:13:57 +02:00
Johan Eliasson
d3107934b0 updates 2022-05-06 20:11:23 +02:00
Johan Eliasson
5ae02605b2 added npm/yarn tabs 2022-05-06 20:08:39 +02:00
Pilou
55864eac30 Merge pull request #522 from nhost/event-triggers-syntax-error
fixed syntax error in Event Triggers docs
2022-05-06 19:59:46 +02:00
Johan Eliasson
b927587d75 correct repo link 2022-05-06 19:34:21 +02:00
Johan Eliasson
e63c45cdaa grammarly updates 2022-05-06 19:29:45 +02:00
Szilárd Dóró
28494d6c1f fixed syntax error in Event Triggers docs 2022-05-06 19:09:51 +02:00
Pilou
6777738c53 Merge pull request #519 from nhost/changeset-release/main
chore: update versions
2022-05-06 15:24:04 +02:00
Szilárd Dóró
34532b1a2f Merge branch 'main' into monorepo-improvements 2022-05-06 14:53:03 +02:00
Pierre-Louis Mercereau
de3257ca7a Merge branch 'main' into feat/improve-errors 2022-05-06 14:46:14 +02:00
Pierre-Louis Mercereau
9d32314065 feat: improve the handling of authentication errors 2022-05-06 14:44:54 +02:00
Johan Eliasson
9edfe408e0 updated template repo 2022-05-06 14:17:33 +02:00
github-actions[bot]
0d60693c27 chore: update versions 2022-05-06 11:43:21 +00:00
Pilou
c159c9c98c Merge pull request #518 from nhost/fix/refresh-token-load
fix: corrections and reshape the react-apollo example
2022-05-06 13:42:05 +02:00
Pierre-Louis Mercereau
58fa2a201c fix: corrections and reshape the react-apollo example 2022-05-06 12:55:17 +02:00
Johan Eliasson
d3c7930b48 all images locally 2022-05-06 12:22:45 +02:00
Johan Eliasson
4a864a9777 store quickstart images locally 2022-05-06 12:12:32 +02:00
Johan Eliasson
50ba5fe2c8 Merge pull request #494 from gdangelo/patch-4
Add content for the React quickstart guide
2022-05-06 11:53:01 +02:00
Johan Eliasson
05e0c42c82 Merge pull request #484 from gdangelo/patch-2
Create "Get started with Nhost CLI" guide
2022-05-06 11:52:49 +02:00
Johan Eliasson
fbc9ff32dd Merge pull request #485 from gdangelo/patch-3
Add content for the Next.js quickstart guide
2022-05-06 11:52:13 +02:00
Johan Eliasson
db4607ccac Merge pull request #516 from nhost/docs-guides
Docs intro of Nhost
2022-05-06 11:50:05 +02:00
Johan Eliasson
95b14557a0 intro 2022-05-06 11:47:29 +02:00
Johan Eliasson
8b527d0fcb Merge pull request #445 from nhost/docs-guides
docs: intro, architecture and quickstarts
2022-05-06 11:43:41 +02:00
Szilárd Dóró
67f0450dac fixed issues with package references in Next.js docs 2022-05-06 11:01:53 +02:00
Pilou
fc50beec5e Merge pull request #513 from nhost/docs/clean-nextjs-intro
remove reference to useless component
2022-05-06 10:42:24 +02:00
Szilárd Dóró
584976d1ad added patch notes 2022-05-06 10:32:13 +02:00
Szilárd Dóró
509ed7d864 Merge branch 'main' into monorepo-improvements 2022-05-06 08:56:34 +02:00
Max Reynolds
71b92363b4 Fix signIn/signUp typo
I think the example should be for signUp here.
2022-05-06 06:25:20 +01:00
Pierre-Louis Mercereau
ed0de2d930 remove reference to useless component 2022-05-05 21:53:37 +02:00
Grégory D'Angelo
c7aa9f7ea9 Edit code snippets to replace Tailwind utility classes with CSS modules
As discussed with Johan. The React template for this guide has also been edited to remove Tailwind CSS and use CSS modules instead.

You can find this template here: https://github.com/gdangelo/cra-template-quickstart-nhost. Please make sure to move it to the Nhost Github repository and publish it to npm.
2022-05-05 19:50:09 +02:00
Grégory D'Angelo
3e6057b4ed Edit code snippets to replace Tailwind utility classes with CSS modules
As discussed with Johan. The Next.js template for this guide has also been edited to remove Tailwind CSS and use CSS modules instead.

You can find this template here: https://github.com/gdangelo/nhost-quickstart-nextjs. Please make sure to move it to the Nhost Github repository.
2022-05-05 19:11:49 +02:00
Pilou
f26e8c3614 Merge pull request #491 from nhost/changeset-release/main
chore: update versions
2022-05-05 16:11:42 +02:00
Pierre-Louis Mercereau
a05a484426 chore: correct changelog 2022-05-05 16:04:33 +02:00
Pierre-Louis Mercereau
4f0d5aa9c0 chore: downgrade major to minor bump 2022-05-05 16:02:23 +02:00
github-actions[bot]
254e362e95 chore: update versions 2022-05-05 13:58:01 +00:00
Pilou
a2a8839694 Merge pull request #507 from nhost/refactor/simplify-and-correct-options
Make code more consistent, implement the 'custom and 'cookie' storage types
2022-05-05 15:56:41 +02:00
Pierre-Louis Mercereau
d12667ccc5 refactor: post-review 2022-05-05 15:22:35 +02:00
Pierre-Louis Mercereau
feb55fe0ad chore: update lockfile 2022-05-05 14:43:12 +02:00
Pilou
b97c0a9c9d Merge branch 'main' into refactor/simplify-and-correct-options 2022-05-05 14:35:08 +02:00
Szilárd Dóró
bb548cd108 added support for TS package references, fixed CI 2022-05-05 14:15:20 +02:00
Szilárd Dóró
adb30c537f updated pnpm-lock.yaml file 2022-05-05 13:53:54 +02:00
Szilárd Dóró
d7d3e8f903 Merge branch 'main' into monorepo-improvements 2022-05-05 13:53:09 +02:00
Pierre-Louis Mercereau
2e98934f75 refactor: expose the interface of NhostReactProvider and use PropsWithChildren type 2022-05-05 13:35:30 +02:00
Szilárd Dóró
8a4064e99f reverted next-transpile-modules change 2022-05-05 13:31:27 +02:00
Pilou
937e28116b Merge pull request #509 from nhost/monorepo-adjustments
Adjustments to the new monorepo setup
2022-05-05 13:27:57 +02:00
Pilou
8cedafc807 Merge pull request #503 from nhost/patch/react-18
Patch/react 18
2022-05-05 13:27:24 +02:00
Pierre-Louis Mercereau
d885fe7b02 refactor: remove direct dependency to @nhost/core 2022-05-05 12:50:55 +02:00
Pierre-Louis Mercereau
b0d7217276 refactor: correct react-apollo-crm tsconfig 2022-05-05 12:38:49 +02:00
Pierre-Louis Mercereau
bfba4ae7ec refactor: make the react examples work inside the monorepo 2022-05-05 12:37:30 +02:00
Pierre-Louis Mercereau
322b433994 docs(example): correct nextjs example 2022-05-05 12:07:20 +02:00
Pierre-Louis Mercereau
6082ba6943 docs: remove part of the doc already automatically generated 2022-05-05 10:54:24 +02:00
Szilárd Dóró
44b12dc0a0 updated DEVELOPERS.md: fixed some typos, added development mode related info 2022-05-05 10:46:43 +02:00
Pierre-Louis Mercereau
1fb1d25a72 chore: remove testing credentials 2022-05-05 10:39:07 +02:00
Pierre-Louis Mercereau
ae4e4e50f6 chore: update changeset 2022-05-05 10:37:22 +02:00
Pierre-Louis Mercereau
185f39e23f fix: don't take previous errors into account when using SMS and deanonymisation 2022-05-05 10:35:49 +02:00
Szilárd Dóró
bf6ee5d360 unified Prettier configuration, temporarily disabled import sorter 2022-05-05 10:28:11 +02:00
Pierre-Louis Mercereau
0dd7cab3bf fix: remove async import 2022-05-04 22:35:18 +02:00
Pierre-Louis Mercereau
47c7380d89 refactor: cooooooooookies
(miom miom miom)
2022-05-04 22:28:13 +02:00
Pierre-Louis Mercereau
b56162a74b refactor: make code more consistent, and implement the 'custom and 'cookie' client storage types 2022-05-04 22:25:17 +02:00
Grégory D'Angelo
1a7007d1cb Remove the CLI and Github connection steps
As discussed with Johan.
2022-05-04 17:58:29 +02:00
Grégory D'Angelo
05d25a54af Remove the CLI and Github connection steps
As discussed with Johan
2022-05-04 17:52:21 +02:00
Szilárd Dóró
9f8bdb504d fixed UMD config 2022-05-04 16:02:13 +02:00
Pierre-Louis Mercereau
aeb8b8afda chore: lint, and update changesets 2022-05-04 14:23:58 +02:00
Pierre-Louis Mercereau
f9e107b008 docs: return errors to the UI 2022-05-04 13:42:30 +02:00
Szilárd Dóró
cd2594f66a fixed linter configs 2022-05-04 13:33:03 +02:00
Szilárd Dóró
c6a3e9f516 restructured project configuration, removed config copy script 2022-05-04 13:15:07 +02:00
Pierre-Louis Mercereau
d748d82483 docs: flesh up the nextjs example 2022-05-04 13:11:00 +02:00
Szilárd Dóró
1bfb1e6d10 Merge branch 'main' into monorepo-improvements 2022-05-04 11:13:13 +02:00
Szilárd Dóró
35fd7b1b7c added root lintstagedrc to gitignore 2022-05-04 11:10:01 +02:00
Szilárd Dóró
04c1ed6955 moved lintstagedrc and tsconfig files to .config folder 2022-05-04 11:02:40 +02:00
Szilárd Dóró
0c591daef4 fixed source code references of docs 2022-05-04 10:54:29 +02:00
Johan Eliasson
2192fdc92e change cta 2022-05-04 09:04:53 +02:00
Johan Eliasson
eec2601a3a architecture 2022-05-04 08:55:17 +02:00
Johan Eliasson
93eaa85b47 Merge branch 'main' into docs-guides 2022-05-04 07:40:53 +02:00
Pierre-Louis Mercereau
4c8a168c02 refactor: update lockfile 2022-05-03 22:12:57 +02:00
Pierre-Louis Mercereau
eb166cf5ee refactor: remove debug code 2022-05-03 22:07:07 +02:00
Pierre-Louis Mercereau
54e1873461 refactor: wrap again the apollo client creation into useEffect to avoid SSR when CSR 2022-05-03 22:02:15 +02:00
Pierre-Louis Mercereau
e5bc3b356c refactor(nextjs): bump to React 18 and Apollo client 3.6.2 2022-05-03 21:43:39 +02:00
Pierre-Louis Mercereau
42edb74057 refactor: upgrade to React 18 2022-05-03 21:20:10 +02:00
Pierre-Louis Mercereau
3ebeae9294 refactor: upgrade react-apollo to React 18 to reproduce the missing attached headers bug 2022-05-03 19:51:50 +02:00
Pilou
24189bd155 Merge pull request #501 from nhost/contributors-readme-action-tjRSlp2hVR
contributors readme action update
2022-05-03 16:47:01 +02:00
github-actions[bot]
5985b18764 contrib-readme-action has updated readme 2022-05-03 14:43:47 +00:00
Pilou
95efcb4de6 Merge pull request #500 from heygambo/patch-1
Adds environment variables to auth service
2022-05-03 16:43:30 +02:00
Christian Gambardella
609d9001f5 Adds environment variables to auth service
I ran into an issue where I couldn't sign up users because the auth service wasn't able to connect to mailhog.
That caused the auth service to not send an email and not respond to the HTTP request.

fixes #499 

I'm wondering if anyone else had this issue. If I'm the only one then maybe this PR is obsolete.
2022-05-03 16:18:36 +02:00
Szilárd Dóró
6f5729eb45 fixed Next.js example configuration 2022-05-03 15:54:21 +02:00
Szilárd Dóró
9bc447dbff fixed pnpm-lock 2022-05-03 15:51:02 +02:00
Szilárd Dóró
d2d0e7fced reverted package versions to leverage pnpm workspace features 2022-05-03 15:48:59 +02:00
Szilárd Dóró
0ad654226b fixed example projects, upgraded Vite to latest version 2022-05-03 13:54:32 +02:00
Szilárd Dóró
9d8f2dea22 UMD module name change for all packages 2022-05-03 11:16:33 +02:00
Szilárd Dóró
f3a44931a5 reverted unnecessary build command change 2022-05-03 08:35:51 +02:00
Pilou
1e44a14b8a Merge pull request #497 from nhost/docs/generate-hasura-auth-openapi
Generate the latest hasura-auth openapi specs
2022-05-02 17:05:26 +02:00
Szilárd Dóró
1c1656441b removed esbuild related packages from pnpm-lock 2022-05-02 17:00:42 +02:00
Szilárd Dóró
5f68f8fe31 fixed build warning caused by a missing global 2022-05-02 16:54:26 +02:00
Szilárd Dóró
961103d7a5 removed individual Vite configs, using unified 2022-05-02 16:27:48 +02:00
Szilárd Dóró
2bebab3f8e fixed ESLint ignore patterns to prevent lint error 2022-05-02 15:11:12 +02:00
Szilárd Dóró
0363abbbb1 fixed CI build and test step 2022-05-02 14:48:47 +02:00
Szilárd Dóró
2f3715d02a fixed linter errors 2022-05-02 14:05:26 +02:00
Szilárd Dóró
7c101e5226 removed unnecessary tsconfig, fixed an issue in NhostClient 2022-05-02 13:52:42 +02:00
Szilárd Dóró
ef943995e2 added umd folder to cached turborepo output 2022-05-02 13:30:56 +02:00
Szilárd Dóró
b6032508bc docs reference update, tsconfig fixes 2022-05-02 12:50:53 +02:00
Szilárd Dóró
a6b00294e7 Merge branch 'main' into monorepo-improvements 2022-05-02 12:17:52 +02:00
Szilárd Dóró
dbfc5ec220 added support for UMD build 2022-05-02 11:55:42 +02:00
Pierre-Louis Mercereau
5917eff5a6 chore: newline 2022-05-02 09:44:38 +02:00
Pierre-Louis Mercereau
f8ee87ad01 feat: smalls script that generates the latest hasura-auth openapi specs 2022-05-02 09:42:24 +02:00
Szilárd Dóró
a7990b363f Merge pull request #496 from nhost/contributors-readme-action-Vits42iSrd
contributors readme action update
2022-05-02 08:59:28 +02:00
github-actions[bot]
ca8ecb4b5c contrib-readme-action has updated readme 2022-05-02 06:48:04 +00:00
Szilárd Dóró
dfe080b8f6 Merge pull request #495 from GavanWilhite/patch-2
Fixed npm <> yarn instructions
2022-05-02 08:47:50 +02:00
Gavan Wilhite
069a5d4d9a Fixed npm <> yarn instructions 2022-05-01 19:42:53 -06:00
Grégory D'Angelo
c9d474ea6c Use .mdx extension instead 2022-04-29 18:30:02 +02:00
Grégory D'Angelo
2afa460263 Use .mdx extension instead 2022-04-29 18:29:35 +02:00
Grégory D'Angelo
776555bdda Add content for the React quickstart guide 2022-04-29 18:27:59 +02:00
Grégory D'Angelo
e0e9729884 Add missing props to NhostApolloProvider 2022-04-29 18:20:21 +02:00
Szilárd Dóró
6ffaf31af5 simplified tsconfig of React libs 2022-04-29 17:33:29 +02:00
Szilárd Dóró
8ec18157bb simplified Vite config of packages, improved TSConfig 2022-04-29 17:31:18 +02:00
Pilou
efccd54641 Merge pull request #492 from nhost/docs/autogen-edit-page
feat: link the 'Edit Page' button to the source code instead of the generated file
2022-04-29 17:02:18 +02:00
Grégory D'Angelo
396dc554d9 Remove sections number + add level 4 titles 2022-04-29 16:36:08 +02:00
Grégory D'Angelo
92f9576ca6 Re-organize sections 2022-04-29 16:16:49 +02:00
Grégory D'Angelo
5cf8ace1bc Add title to code snippets + fix syntax highlighting + add tabs + admonitions 2022-04-29 16:10:54 +02:00
Grégory D'Angelo
cf1518ab75 Use admonitions instead of basic Markdown quotes 2022-04-29 15:38:30 +02:00
Grégory D'Angelo
b8c0dba6de Update language for syntax highlighting to bash + add titles 2022-04-29 15:31:53 +02:00
Pierre-Louis Mercereau
116c8eba66 fix: close img tags 2022-04-29 14:52:13 +02:00
Pierre-Louis Mercereau
a9bc698dae fix: close img tags 2022-04-29 14:49:00 +02:00
Szilárd Dóró
175ab26e04 Merge branch 'main' into monorepo-improvements 2022-04-29 13:54:29 +02:00
Szilárd Dóró
eb2d064cbe restored removed docs pages 2022-04-29 13:38:53 +02:00
Szilárd Dóró
17d2c8c3d9 bump axios to 0.26.0 so that all packages use the same version 2022-04-29 13:32:54 +02:00
Szilárd Dóró
4e0aab1bb2 removed unnecessary @nhost/config package, excluded several packages from CI command 2022-04-29 12:33:53 +02:00
Pilou
a3357265ec Merge pull request #480 from nhost/docs/algolia
docs: enable algolia search
2022-04-29 12:33:20 +02:00
Pierre-Louis Mercereau
494d8127dc refactor: simplify 2022-04-29 12:31:15 +02:00
Pierre-Louis Mercereau
57b628a255 refactor: remove useless condition 2022-04-29 12:28:31 +02:00
Pierre-Louis Mercereau
98b30a5c5e Merge branch 'main' into docs/autogen-edit-page 2022-04-29 12:26:02 +02:00
Pierre-Louis Mercereau
48afcf415d feat: link the 'Edit Page' button to the source code instead of the generated file 2022-04-29 12:24:33 +02:00
Johan Eliasson
58b9488af8 update setting 2022-04-29 11:48:42 +02:00
Pilou
e49528d43e Merge pull request #488 from nhost/chore/rename-user-hooks
fix: rename user data hooks to make them all start with `userUser...`
2022-04-29 11:47:33 +02:00
Pilou
ab0f5582e5 Merge pull request #489 from nhost/docs/developers-guide
Basic developer guide
2022-04-29 11:47:17 +02:00
Pierre-Louis Mercereau
b499548503 post review 2022-04-29 10:30:29 +02:00
Pilou
fbc15cfee1 Merge pull request #452 from nhost/441-user_id-not-seen-in-the-screenshots-before-the-permissions-section-of-todoapp
docs: correct docs for `user_id` column
2022-04-29 09:43:03 +02:00
Pierre-Louis Mercereau
8788de83e8 docs: basic developer guide 2022-04-29 09:14:41 +02:00
Pierre-Louis Mercereau
1fb51a7bed fix: rename user data hooks to make them all start with userUser... 2022-04-29 08:31:32 +02:00
Pilou
365b806755 Merge pull request #487 from nhost/changeset-release/main
chore: update versions
2022-04-28 23:55:00 +02:00
github-actions[bot]
74025a2d90 chore: update versions 2022-04-28 21:51:11 +00:00
Pilou
ebd6f86ea3 Merge pull request #486 from nhost/fix/fine-tune-nextjs
fix: get the refresh token in the right place in the url
2022-04-28 23:50:19 +02:00
Pierre-Louis Mercereau
7b23d33d9b fix: get the refresh token in the right place in the url 2022-04-28 22:18:48 +02:00
Grégory D'Angelo
87fc565b14 Add content for the Next.js quickstart guide 2022-04-28 19:46:06 +02:00
Grégory D'Angelo
ed46a7a6f9 Add missing file extension 2022-04-28 19:28:51 +02:00
Grégory D'Angelo
6749bf3486 Rename file to get-started-with-nhost-cli 2022-04-28 19:26:53 +02:00
Grégory D'Angelo
b32c1bab39 Add "Get help" section 2022-04-28 19:25:17 +02:00
Pierre-Louis Mercereau
de177710f7 chore: bump correct version number, and trigger release 2022-04-28 18:39:58 +02:00
Pierre-Louis Mercereau
eebfddb48e build: bump nextjs to correct version 2022-04-28 16:52:17 +02:00
Pilou
f5df7eaa2d Merge pull request #457 from nhost/changeset-release/main
chore: update versions
2022-04-28 16:31:09 +02:00
Pierre-Louis Mercereau
0b4028b1d6 chore: remove duplicate lines in changelog 2022-04-28 15:57:20 +02:00
github-actions[bot]
f2da21026b chore: update versions 2022-04-28 13:48:50 +00:00
Pilou
a8233ea621 Merge pull request #461 from nhost/feat/get-claim
feat: add accessors for decoded access token and Hasura claims
2022-04-28 15:47:30 +02:00
Pierre-Louis Mercereau
f300d8b9f1 build: update lintstagedrc 2022-04-28 15:26:29 +02:00
Pierre-Louis Mercereau
3b625acd96 Merge branch 'main' into feat/get-claim 2022-04-28 15:24:46 +02:00
Pilou
116e23cb13 Merge pull request #459 from nhost/feat/capture-url-errors
feat: capture url errors & improved SSR / NextJs startup
2022-04-28 15:22:54 +02:00
Szilárd Dóró
1bde3e6516 dependency optimization, build improvements 2022-04-28 14:48:50 +02:00
Pierre-Louis Mercereau
954aa43e49 refactor: adjustments from review 2022-04-28 14:01:18 +02:00
Pierre-Louis Mercereau
de6f862c4c style: remove dead code and add minor piece of doc 2022-04-28 13:54:29 +02:00
Pierre-Louis Mercereau
5025333fb4 Merge branch 'main' into feat/capture-url-errors 2022-04-28 13:44:14 +02:00
Pilou
b3991ea9d9 Merge pull request #482 from nhost/docs/404
docs: custom 404 page
2022-04-28 13:42:54 +02:00
Szilárd Dóró
3674f11183 upgraded turborepo, updated turborepo commands 2022-04-28 13:31:48 +02:00
Pierre-Louis Mercereau
239db617f3 docs: clean file 2022-04-28 12:48:07 +02:00
Szilárd Dóró
76b3cb4643 Merge branch 'main' into monorepo-improvements 2022-04-28 12:34:45 +02:00
Szilárd Dóró
6d6c8b3e2e Merge pull request #481 from nhost/fix/docgen-tags 2022-04-28 12:24:03 +02:00
Grégory D'Angelo
5a06ecbb10 Create "Get started with Nhost CLI" guide 2022-04-28 11:26:17 +02:00
Pierre-Louis Mercereau
169f163c99 docs: custom 404 page 2022-04-28 10:53:35 +02:00
Szilárd Dóró
5ddd7eda22 fixed some errors caused by undefined values 2022-04-28 10:49:03 +02:00
Szilárd Dóró
556190dfc5 Merge branch 'main' into monorepo-improvements 2022-04-28 10:44:15 +02:00
Szilárd Dóró
00d50f404a temporary support for link removal from TSDoc comments, renamed __tsdoc__ folder to .docgen 2022-04-28 10:21:06 +02:00
Pierre-Louis Mercereau
b52b4fca2d feat: complete NextJs 2022-04-27 22:18:03 +02:00
Pierre-Louis Mercereau
56b1adfa81 docs: enable algolia search 2022-04-27 17:25:34 +02:00
Pierre-Louis Mercereau
9f55f4890e chore: merge main 2022-04-27 16:44:19 +02:00
Szilárd Dóró
284890b437 Merge pull request #477 from nhost/docgen-improvements
DocGen improvements
2022-04-27 16:22:05 +02:00
Szilárd Dóró
1e3cb855f0 improved function overloads in auto-generated docs 2022-04-27 16:12:41 +02:00
Pierre-Louis Mercereau
aaf575f0af chore: remove dev code 2022-04-27 16:09:30 +02:00
Pierre-Louis Mercereau
ff3427ccdb chore: update changeset title 2022-04-27 16:08:40 +02:00
Szilárd Dóró
3834d80a0a improved the way function overloads are displayed
fixed an issue where line breaks broke the layout of parameter table fragments
2022-04-27 15:57:34 +02:00
Pierre-Louis Mercereau
8fcc3fd560 Merge branch 'main' into feat/capture-url-errors 2022-04-27 15:56:04 +02:00
Pierre-Louis Mercereau
616e320421 refactor: simplify startup 2022-04-27 15:55:04 +02:00
Pilou
ff8fdc4db4 Merge pull request #476 from nhost/contributors-readme-action-84g__a20xD
contributors readme action update
2022-04-27 15:43:27 +02:00
Szilárd Dóró
b732bc51e8 fixed an issue where multiple function signatures were not rendered properly in generated docs 2022-04-27 14:42:01 +02:00
Pierre-Louis Mercereau
8b88d6c553 refactor: augment useAuthenticationState instead of creating useAuthenticationError 2022-04-27 14:26:14 +02:00
Szilárd Dóró
af192fbb66 updated lint-staged config 2022-04-27 14:23:27 +02:00
Szilárd Dóró
b7c031d7e0 added deprecation indicator to sidebar items if applicable 2022-04-27 14:21:31 +02:00
Pierre-Louis Mercereau
05e91d93a8 fix: check if window existd 2022-04-27 14:20:52 +02:00
Pierre-Louis Mercereau
261f001a99 fix(nextjs): correct refresh method 2022-04-27 14:14:46 +02:00
Szilárd Dóró
ddb965c7cf added warning message to auto-generated markdown files 2022-04-27 14:10:17 +02:00
github-actions[bot]
ff8af4912b contrib-readme-action has updated readme 2022-04-27 11:42:13 +00:00
Pilou
948aebcf42 Merge pull request #472 from jladuval/patch-1
Docs: Update event-triggers.md with environment variable example
2022-04-27 13:41:57 +02:00
Szilárd Dóró
51a4d7a343 Merge pull request #474 from nhost/fix/docs-redirects
fix: Docs redirects
2022-04-27 13:17:41 +02:00
Johan Eliasson
d521218146 Merge pull request #475 from nhost/typo-hbuyg87y9
Typo
2022-04-27 13:08:06 +02:00
Johan Eliasson
9a1685c2eb typo 2022-04-27 12:55:43 +02:00
Szilárd Dóró
fb8f58503f updated CODEOWNERS 2022-04-27 12:31:02 +02:00
Szilárd Dóró
86409c2f18 changed React Hooks redirect 2022-04-27 12:26:36 +02:00
Szilárd Dóró
f7d8c061a0 added redirects from previously removed docs 2022-04-27 12:23:57 +02:00
Szilárd Dóró
eb59a07c3f Merge pull request #453 from nhost/feat/docgen
feat: Auto-generate documentation from TSDoc
2022-04-27 12:07:58 +02:00
Szilárd Dóró
27add80f95 added index page to JavaScript docs 2022-04-27 11:59:04 +02:00
Szilárd Dóró
cc60a845f3 fixes HasuraStorageClient examples to use code block 2022-04-27 10:53:02 +02:00
Szilárd Dóró
aeea44e4e8 fixed HasuraAuthClient examples to use code block 2022-04-27 10:51:35 +02:00
Jacob Duval
d273825cee Update event-triggers.md with environment variable example
Show how environment variables are used with the correct formatting. I had to search around a while to find the correct {{}} format.
2022-04-27 10:44:57 +02:00
Szilárd Dóró
177733f4b1 added deprecation note to parameters and parameter tables 2022-04-27 10:40:50 +02:00
Szilárd Dóró
efd33a7115 updated docs according to code changes 2022-04-27 10:04:08 +02:00
Szilárd Dóró
e4fe166992 Merge branch 'main' into feat/docgen 2022-04-27 10:02:34 +02:00
Pierre-Louis Mercereau
d9f221b625 feat: get refresh token from url in Next, and remove the refresh token from the url when possible 2022-04-27 09:55:42 +02:00
Szilárd Dóró
e0f5bf3396 fixed example in hasura-auth-client 2022-04-27 09:50:23 +02:00
Szilárd Dóró
17bd23460f added lint-staged configuration 2022-04-27 09:16:12 +02:00
Szilárd Dóró
52c30c25a9 expand Reference > JavaScript menu by default 2022-04-26 17:11:00 +02:00
Szilárd Dóró
989bc54544 added support for DocGen parallelization, improved DocGen configuration 2022-04-26 17:05:07 +02:00
Szilárd Dóró
5781cb0f9c restored accidentally removed docs pages 2022-04-26 15:51:26 +02:00
Szilárd Dóró
24f9ed4c4d fixed slugs, re-generated docs 2022-04-26 15:25:31 +02:00
Szilárd Dóró
2b447af8a7 Merge branch 'feat/docgen' of https://github.com/nhost/nhost into feat/docgen 2022-04-26 14:57:06 +02:00
Szilárd Dóró
2485c83de3 updated documentation URLs, fixed auto-generated documentation slugs 2022-04-26 14:53:26 +02:00
Pilou
707877477f Merge pull request #465 from nhost/chore/inline-react-doc
docs(react): add inline documentation
2022-04-26 14:32:15 +02:00
Pierre-Louis Mercereau
756e1af52d chore: merge 2022-04-26 14:31:35 +02:00
Pierre-Louis Mercereau
7f771e2e8f pre-merge 2022-04-26 14:29:25 +02:00
Szilárd Dóró
a737863c2b added support for flattened navigation structure on References page 2022-04-26 13:32:24 +02:00
Pierre-Louis Mercereau
ca2a61089a docs: add missing backticks 2022-04-26 12:19:53 +02:00
Szilárd Dóró
7432db0fe8 created custom sidebar mapping to support appropriate structure 2022-04-26 12:10:38 +02:00
Pierre-Louis Mercereau
9c25e65df6 docs(react): add inline documentation 2022-04-26 12:06:51 +02:00
Szilárd Dóró
e345895fd8 generated React, Next.js, Nhost JS documentation, fixed issues 2022-04-26 11:55:53 +02:00
Szilárd Dóró
cba7996dcf generated React, Next.js, Nhost JS documentation, fixed issues 2022-04-26 10:58:03 +02:00
Johan Eliasson
d7ceda6ae6 Merge pull request #464 from nhost/contributors-readme-action-yLZgG3Dxtk
contributors readme action update
2022-04-26 08:36:39 +02:00
github-actions[bot]
4e19b7309d contrib-readme-action has updated readme 2022-04-25 18:21:46 +00:00
David Barroso
de8a7d5512 Merge pull request #449 from nhost/dbarroso/update-docker-compose
update hasura-storage example
2022-04-25 20:21:32 +02:00
Szilárd Dóró
69f3a84bf5 vite config to exclude external dependencies from bundle 2022-04-25 17:23:24 +02:00
Szilárd Dóró
16dcd314bb replaced esbuild with Vite, unified entry point and publish configuration of packages 2022-04-25 14:45:14 +02:00
Pierre-Louis Mercereau
7e7aa5adc4 refactor: explain 2022-04-25 14:11:22 +02:00
Pierre-Louis Mercereau
1ed948952a refactor: remove mock credentials 2022-04-25 14:07:47 +02:00
Pilou
55b0a8f4b9 Merge pull request #458 from nhost/examples/xstate-inspector
react-apollo example: activate xstate inspector with an environment variable
2022-04-25 13:37:43 +02:00
Pierre-Louis Mercereau
1ce55c5568 feat: add aceessors for decoded access token and Hasura claims 2022-04-25 13:24:07 +02:00
Pierre-Louis Mercereau
fabd1da04c feat: new useAuthenticationError hook 2022-04-25 11:19:59 +02:00
Pierre-Louis Mercereau
53f5226d0c feat: capture hasura-auth errors from the url 2022-04-25 11:16:48 +02:00
Pilou
e339cba384 Merge pull request #450 from nhost/fix/filter-logs
Remove filtering of `useLayoutEffect` from logs
2022-04-25 11:14:05 +02:00
Pierre-Louis Mercereau
c14d12e04d docs: activate xstate inspector with an environment variable 2022-04-25 10:57:42 +02:00
Szilárd Dóró
03370da2f4 added DocGen support for React package, generated default React SDK references 2022-04-25 10:46:06 +02:00
Pilou
87d32b2639 Merge pull request #451 from nhost/chore/reprecate-bad-naming
Rename `autoLogin` to `autoSignIn`, and deprecate `autoLogin`
2022-04-25 10:13:08 +02:00
Pilou
61b5fb549c Merge pull request #456 from nhost/docs/use-display-name
docs: `useDisplayName` instead of `displayName`
2022-04-25 10:12:52 +02:00
Szilárd Dóró
28cd8dc5c5 resolved conflicts with main branch 2022-04-25 10:06:33 +02:00
Szilárd Dóró
fb93d8c1af Merge branch 'main' into feat/docgen 2022-04-25 10:05:41 +02:00
Pierre-Louis Mercereau
f4e6aea9c1 docs: fix incorrect example 2022-04-25 09:45:40 +02:00
Johan Eliasson
65d61cf4b8 update 2022-04-25 09:40:23 +02:00
Johan Eliasson
a8d5214b2f grammerly updates 2022-04-25 09:39:14 +02:00
Johan Eliasson
f9e5283fc3 correct docs for column 2022-04-25 09:35:18 +02:00
Pierre-Louis Mercereau
d49b837abb fix: rename autoLogin to autoSignIn, and deprecate autoLogin 2022-04-25 09:09:19 +02:00
Pierre-Louis Mercereau
49545c058b fix: remove filtering of useLayoutEffect from logs 2022-04-25 08:40:34 +02:00
David Barroso
765340f7b2 update hasura-storage example 2022-04-25 08:30:39 +02:00
Johan Eliasson
5a212aaa12 link fix 2022-04-22 22:34:45 +02:00
Johan Eliasson
79056d8b48 update 2022-04-22 22:30:02 +02:00
Johan Eliasson
f86883df88 new menu strucutre 2022-04-22 22:20:42 +02:00
Szilárd Dóró
e5f00394ae added tests for getNestedParametersFromParameter 2022-04-22 16:41:04 +02:00
Szilárd Dóró
dd08aef4cc added tests for helper functions, improved verbose logging 2022-04-22 15:55:08 +02:00
Szilárd Dóró
4ab85815a0 introduced support for "alias" tag, added tests for DeprecationNoteFragment and CommentTagFragment 2022-04-22 15:18:53 +02:00
Szilárd Dóró
1b0902079b changed reference paths to use root path, improved some examples of HasuraAuthClient 2022-04-22 12:55:07 +02:00
Szilárd Dóró
f719d47ed3 created command for Storage docs generation, added initial docs generated with the tool 2022-04-22 11:23:54 +02:00
Szilárd Dóró
8cc88533b1 fixed class references 2022-04-22 10:57:41 +02:00
Szilárd Dóró
71de2bd0c5 added custom styling for optional / required labels of parameters
improved prettier formatter of classes, functions and types
2022-04-21 22:50:40 +02:00
Szilárd Dóró
66d204331b improved function signature formatting, union and intersection types 2022-04-21 22:31:17 +02:00
Szilárd Dóró
ee288fbc5f added tests for ClassTemplate, improved typings of signatures 2022-04-21 21:59:26 +02:00
Szilárd Dóró
1a38b5dca3 fixed parameter reference generator issues, added option to wrap or unwrap values to label generator 2022-04-21 19:39:38 +02:00
Szilárd Dóró
e0bd8cf14b moved docgen to packages, created temporary scripts to execute docgen procedure 2022-04-21 18:21:36 +02:00
Szilárd Dóró
1da0ff9109 fixed ESLint issues, improved error handling, improved DocGen state management 2022-04-21 14:09:44 +02:00
Szilárd Dóró
c08230ae95 disabled import sort command in DocGen because of the Prettier plugin 2022-04-21 12:04:43 +02:00
Szilárd Dóró
18df8921fd initial DocGen code 2022-04-21 11:44:31 +02:00
623 changed files with 28439 additions and 6192 deletions

View File

@@ -1,50 +0,0 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"ignorePatterns": ["**/dist", "**/build", "**/.next"],
"extends": ["react-app", "plugin:react/recommended", "plugin:react-hooks/recommended"],
"parserOptions": {
// "project": "./tsconfig.json"
"project": ["packages/*/tsconfig.json", "examples/*/tsconfig.json"]
},
"plugins": ["react", "@typescript-eslint", "react-hooks", "simple-import-sort"],
"rules": {
"no-use-before-define": "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": [
"error",
{
"groups": [
// Node.js builtins. You could also generate this regex if you use a `.js` config.
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
[
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)"
],
// Packages
["^\\w"],
// Internal packages.
["^(@|config/)(/*|$)"],
// Side effect imports.
["^\\u0000"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.s?css$"]
]
}
],
"import/no-anonymous-default-export": [
"error",
{
"allowArrowFunction": true,
"allowAnonymousFunction": true
}
]
}
}

View File

@@ -1,30 +0,0 @@
const esbuild = require('esbuild')
// Automatically exclude all node_modules from the bundled version
const { nodeExternalsPlugin } = require('esbuild-node-externals')
esbuild
.build({
entryPoints: ['./src/index.ts'],
outfile: 'dist/index.cjs.js',
bundle: true,
minify: true,
platform: 'node',
format: 'cjs',
sourcemap: true,
target: 'node14',
plugins: [nodeExternalsPlugin()]
})
.catch(() => process.exit(1))
esbuild
.build({
entryPoints: ['./src/index.ts'],
outfile: 'dist/index.es.js',
bundle: true,
minify: true,
platform: 'browser',
format: 'esm',
sourcemap: true,
target: 'es2019'
})
.catch(() => process.exit(1))

View File

@@ -1,7 +0,0 @@
const base = require('./jest.config.base.js')
module.exports = {
...base,
projects: ['<rootDir>/packages/*/jest.config.js'],
coverageDirectory: '<rootDir>/coverage/'
}

View File

@@ -1,50 +0,0 @@
import fs from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import tsconfigPaths from 'vite-tsconfig-paths'
import react from '@vitejs/plugin-react'
const PWD = process.env.PWD
const pkg = require(path.join(PWD, 'package.json'))
const tsEntry = path.resolve(PWD, 'src/index.ts')
const entry = fs.existsSync(tsEntry) ? tsEntry : tsEntry.replace('.ts', '.tsx')
/**
* @type {import('vite').UserConfig}
*/
export default defineConfig({
plugins: [
react(),
tsconfigPaths(),
dts({
exclude: ['**/*.spec.ts', '**/*.test.ts', '**/tests/**'],
afterBuild: () => {
const types = fs.readdirSync(path.join(PWD, 'dist/src'))
types.forEach((file) => {
fs.renameSync(path.join(PWD, 'dist/src', file), path.join(PWD, 'dist', file))
})
fs.rmdirSync(path.join(PWD, 'dist/src'))
}
})
],
build: {
lib: {
entry,
name: pkg.name,
fileName: 'index'
},
rollupOptions: {
external: ['react', '@nhost/react'],
output: {
globals: {
react: 'react',
'@nhost/react': '@nhost/react'
}
}
}
}
})

1
.github/CODEOWNERS vendored
View File

@@ -2,6 +2,7 @@
# https://help.github.com/en/articles/about-code-owners
/packages @plmercereau
/packages/docgen @szilarddoro
/.github/workflows @plmercereau
/docs/ @guicurcio
/examples/ @plmercereau @guicurcio @FuzzyReason

View File

@@ -9,6 +9,7 @@ on:
- 'examples/**'
- 'assets/**'
- '**.md'
- '!.changeset/**'
- 'LICENSE'
jobs:

17
.gitignore vendored
View File

@@ -15,11 +15,11 @@ logs/
/.vscode/
.eslintcache
.yarnclean
.husky
# Directories
coverage/
dist/
umd/
lib/
node_modules/
tmp/
@@ -33,16 +33,15 @@ tmp/
*.map
todo.md
# Generated configs
# Config files that are not part of the repository root anymore. Should be removed in the future.
/.eslintignore
/.eslintrc
/.prettierignore
/prettier.config.js
/.eslintrc*
/vite.*.js
/jest.*.js
/*tsconfig*.json
/esbuild.*.js
!.config/**
!config/**
*.tsbuildinfo
@@ -50,4 +49,8 @@ todo.md
.netlify
.monorepo-example
.next
.next
# TypeDoc output
.docgen

1
.husky/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

6
.lintstagedrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"packages/(docgen|hasura-auth-js|hasura-storage-js|nextjs|nhost-js|react|core)/src/**/*.{js,ts,jsx,tsx}": [
"pnpm docgen",
"git add docs"
]
}

View File

@@ -11,6 +11,11 @@ module.exports = {
tabWidth: 2,
trailingComma: 'none',
useTabs: false,
// TODO: add import sort configuration to match ESLint rules
// plugins: ['./node_modules/@trivago/prettier-plugin-sort-imports'],
// importOrderSeparation: true,
// importOrderSortSpecifiers: true
plugins: [],
overrides: [
{
files: ['*.json', '*.yaml'],

View File

@@ -24,6 +24,8 @@ If you find an Issue that addresses the problem you're having, please add your r
### Pull Requests
Please have a look at our [developers guide](https://github.com/nhost/nhost/blob/main/DEVELOPERS.md) to start coding!
PRs to our libraries are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general, PRs should:
- Only fix/add the functionality in question **OR** address wide-spread whitespace/style issues, not both.

98
DEVELOPERS.md Normal file
View File

@@ -0,0 +1,98 @@
# Developer guide
## Requirements
- We use [pnpm](https://pnpm.io/) as a package manager to speed up development and builds, and as a basis for our monorepo. You need to make sure it's installed on your machine. There are [several ways to install it](https://pnpm.io/installation), but the easiest way is with `npm`:
```sh
$ npm install -g pnpm
```
- Our tests and examples use the Nhost CLI, to run the backend services locally. You can follow the installation instructions in [our documentation](https://docs.nhost.io/get-started/cli-workflow/install-cli).
## Get started
### Installation
First, clone this repository:
```sh
git clone https://github.com/nhost/nhost
```
Then, install the dependencies with `pnpm`:
```sh
$ cd nhost
$ pnpm install
```
### Development
Although package references are correctly updated on the fly for TypeScript, example projects won't
see the changes because they are depending on the build output. To fix this, you can run packages
in development mode.
Running packages in development mode is as simple as:
```sh
$ pnpm dev
```
Our packages are linked together using [PNPM's workspace](https://pnpm.io/workspaces) feature. Vite automatically detects changes in the dependencies and rebuilds everything, so that the changes are immediately reflected in the other packages.
### Use examples
Examples are a great way to test your changes in practice. Make sure you've `pnpm dev` running in your terminal and then run an example.
Let's follow the instructions to run [react-apollo example](https://github.com/nhost/nhost/blob/main/examples/react-apollo/README.md).
## Run the documentation website locally
The easier way to contribute to our documentation is to go to the `docs` folder and follow the [instructions to start local development](https://github.com/nhost/nhost/blob/main/docs/README.md):
```sh
$ cd docs
# not necessary if you've already done this step somewhere in the repository
$ pnpm install
$ pnpm start
```
## Run test suites
In order to run tests, the Nhost testing backend should be running locally. You can run it from a separate terminal:
```sh
$ cd examples/testing-project
$ nhost -d
```
Once Nhost is started locally, you can run the tests with the following command from the repository root:
```sh
$ pnpm test
```
## Changesets
If you've made changes to the packages, you must describe those changes so that they can be reflected in the next release.
We use [changesets](https://github.com/changesets/changesets) to support our versioning and release workflows. When you submit a pull request, a bot checks if some changesets are present, and if not, it directs you to add them.
The most comprehensive way to add a changeset is to run the following command in the repository root:
```sh
$ pnpm changeset
```
This will create a file in the `.changeset` directory. You can edit it to give more details about the change you just made.
You can take a look at the changeset documentation: [How to add a changeset](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).
## Committing changes
You'll notice that `git commit` takes a few seconds to run. We set a commit hook that scans the changes in the code, automatically generates documentation from the inline [TSDoc](https://tsdoc.org/) annotations, and adds these generated documentation files to the commit. They automatically update the [reference documentation](https://docs.nhost.io/reference).
<!-- ## Good practices
- lint
- prettier
- documentation -->

View File

@@ -98,7 +98,7 @@ Nhost is frontend agnostic, which means Nhost works with all frontend frameworks
Nhost libraries and tools
- [JavaScript/TypeScript SDK](https://docs.nhost.io/reference/sdk)
- [JavaScript/TypeScript SDK](https://docs.nhost.io/reference/javascript)
- [Dart and Flutter SDK](https://github.com/nhost/nhost-dart)
- [Nhost CLI](https://docs.nhost.io/reference/cli)
- [Nhost React](https://docs.nhost.io/reference/react)
@@ -120,7 +120,7 @@ Here are some ways of contributing to making Nhost better:
- **[Try out Nhost](https://docs.nhost.io/get-started/quick-start)**, and think of ways to make the service better. Let us know here on GitHub.
- Join our [Discord](https://discord.com/invite/9V7Qb2U) and connect with other members to share and learn from.
- Send a pull request to any of our [open source repositories](https://github.com/nhost) on Github. Check our [contribution guide](https://github.com/nhost/nhost/blob/main/CONTRIBUTING.md) for more details about how to contribute. We're looking forward to your contribution!
- Send a pull request to any of our [open source repositories](https://github.com/nhost) on Github. Check our [contribution guide](https://github.com/nhost/nhost/blob/main/CONTRIBUTING.md) and our [developers guide](https://github.com/nhost/nhost/blob/main/DEVELOPERS.md) for more details about how to contribute. We're looking forward to your contribution!
### Contributors
@@ -134,6 +134,13 @@ Here are some ways of contributing to making Nhost better:
<sub><b>Pilou</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/szilarddoro">
<img src="https://avatars.githubusercontent.com/u/310881?v=4" width="100;" alt="szilarddoro"/>
<br />
<sub><b>Szilárd Dóró</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/elitan">
<img src="https://avatars.githubusercontent.com/u/331818?v=4" width="100;" alt="elitan"/>
@@ -142,10 +149,10 @@ Here are some ways of contributing to making Nhost better:
</a>
</td>
<td align="center">
<a href="https://github.com/szilarddoro">
<img src="https://avatars.githubusercontent.com/u/310881?v=4" width="100;" alt="szilarddoro"/>
<a href="https://github.com/gdangelo">
<img src="https://avatars.githubusercontent.com/u/4352286?v=4" width="100;" alt="gdangelo"/>
<br />
<sub><b>Szilárd Dóró</b></sub>
<sub><b>Grégory D'Angelo</b></sub>
</a>
</td>
<td align="center">
@@ -161,15 +168,15 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Subha Das</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/guicurcio">
<img src="https://avatars.githubusercontent.com/u/20285232?v=4" width="100;" alt="guicurcio"/>
<br />
<sub><b>Guido Curcio</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/sebagudelo">
<img src="https://avatars.githubusercontent.com/u/43288271?v=4" width="100;" alt="sebagudelo"/>
@@ -184,13 +191,6 @@ Here are some ways of contributing to making Nhost better:
<sub><b>Mrinal Wahal</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/gdangelo">
<img src="https://avatars.githubusercontent.com/u/4352286?v=4" width="100;" alt="gdangelo"/>
<br />
<sub><b>Grégory D'Angelo</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/FuzzyReason">
<img src="https://avatars.githubusercontent.com/u/62517920?v=4" width="100;" alt="FuzzyReason"/>
@@ -213,6 +213,13 @@ Here are some ways of contributing to making Nhost better:
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/dbarrosop">
<img src="https://avatars.githubusercontent.com/u/6246622?v=4" width="100;" alt="dbarrosop"/>
<br />
<sub><b>David Barroso</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/hajek-raven">
<img src="https://avatars.githubusercontent.com/u/7288737?v=4" width="100;" alt="hajek-raven"/>
@@ -220,6 +227,13 @@ Here are some ways of contributing to making Nhost better:
<sub><b>Filip Hájek</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/GavanWilhite">
<img src="https://avatars.githubusercontent.com/u/2085119?v=4" width="100;" alt="GavanWilhite"/>
<br />
<sub><b>Gavan Wilhite</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/jerryjappinen">
<img src="https://avatars.githubusercontent.com/u/1101002?v=4" width="100;" alt="jerryjappinen"/>
@@ -240,7 +254,8 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Pratim</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/Savinvadim1312">
<img src="https://avatars.githubusercontent.com/u/16936043?v=4" width="100;" alt="Savinvadim1312"/>
@@ -254,8 +269,7 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Amir Ahmic</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/akd-io">
<img src="https://avatars.githubusercontent.com/u/30059155?v=4" width="100;" alt="akd-io"/>
@@ -263,6 +277,13 @@ Here are some ways of contributing to making Nhost better:
<sub><b>Anders Kjær Damgaard</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/heygambo">
<img src="https://avatars.githubusercontent.com/u/449438?v=4" width="100;" alt="heygambo"/>
<br />
<sub><b>Christian Gambardella</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/rustyb">
<img src="https://avatars.githubusercontent.com/u/53086?v=4" width="100;" alt="rustyb"/>
@@ -276,12 +297,13 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Dominic Garms</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/GavanWilhite">
<img src="https://avatars.githubusercontent.com/u/2085119?v=4" width="100;" alt="GavanWilhite"/>
<a href="https://github.com/gaurav1999">
<img src="https://avatars.githubusercontent.com/u/20752142?v=4" width="100;" alt="gaurav1999"/>
<br />
<sub><b>Gavan Wilhite</b></sub>
<sub><b>Gaurav Agrawal</b></sub>
</a>
</td>
<td align="center">
@@ -297,15 +319,29 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Hoang Do</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/jladuval">
<img src="https://avatars.githubusercontent.com/u/1935359?v=4" width="100;" alt="jladuval"/>
<br />
<sub><b>Jacob Duval</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/MarcelloTheArcane">
<img src="https://avatars.githubusercontent.com/u/21159570?v=4" width="100;" alt="MarcelloTheArcane"/>
<br />
<sub><b>Max Reynolds</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/ghoshnirmalya">
<img src="https://avatars.githubusercontent.com/u/6391763?v=4" width="100;" alt="ghoshnirmalya"/>
<br />
<sub><b>Nirmalya Ghosh</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/quentin-decre">
<img src="https://avatars.githubusercontent.com/u/1137511?v=4" width="100;" alt="quentin-decre"/>

65
config/.eslintrc.js Normal file
View File

@@ -0,0 +1,65 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
ignorePatterns: [
'dist',
'umd',
'build',
'.next',
'node_modules',
'tsup.config.ts',
'__tests__',
'__mocks__',
'*.test.ts',
'*.test.tsx',
'*.spec.ts',
'*.spec.tsx',
'tests/**/*.ts',
'tests/**/*.d.ts'
],
extends: ['react-app', 'plugin:react/recommended', 'plugin:react-hooks/recommended'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
plugins: ['react', '@typescript-eslint', 'react-hooks', 'simple-import-sort'],
rules: {
'react/prop-types': 'off',
'no-use-before-define': 'off',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': [
'error',
{
groups: [
// Node.js builtins. You could also generate this regex if you use a `.js` config.
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
[
'^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)'
],
// Packages
['^\\w'],
// Internal packages.
['^(@|config/)(/*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports.
['^.+\\.s?css$']
]
}
],
'import/no-anonymous-default-export': [
'error',
{
allowArrowFunction: true,
allowAnonymousFunction: true
}
]
}
}

View File

@@ -7,7 +7,6 @@ module.exports = {
testRegex: '(/tests/.*.(test|spec)).(jsx?|tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverage: true,
// coveragePathIgnorePatterns: ['(tests/.*.mock).(jsx?|tsx?)$'],
verbose: true,
testTimeout: 30000,
globals: {

15
config/jest.config.js Normal file
View File

@@ -0,0 +1,15 @@
module.exports = {
rootDir: process.cwd(),
preset: 'ts-jest',
collectCoverage: true,
coverageProvider: 'v8',
coverageDirectory: '<rootDir>/coverage',
clearMocks: true,
verbose: true,
testTimeout: 30000,
globals: {
'ts-jest': {
isolatedModules: true
}
}
}

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Library",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"jsx": "preserve"
}
}

56
config/tsconfig.base.json Normal file
View File

@@ -0,0 +1,56 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"strict": true,
"isolatedModules": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"moduleResolution": "node",
"target": "ES6",
"module": "CommonJS",
"lib": [
"es5",
"dom",
"es2015.promise",
"es2015.symbol",
"es2015.iterable",
"es2015.collection",
"es2015.symbol.wellknown",
"es2015.core",
"es2017.object",
"es2017.string"
],
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": true,
"types": ["node"],
"typeRoots": [
"./node_modules/@types", "**/*/dist", "**/*/build", "**/*/.next", "**/*/umd"
],
"paths": {
"@nhost/apollo": ["../packages/apollo/src/index.ts"],
"@nhost/core": ["../packages/core/src/index.ts"],
"@nhost/docgen": ["../packages/docgen/src/index.ts"],
"@nhost/hasura-auth-js": ["../packages/hasura-auth-js/src/index.ts"],
"@nhost/hasura-storage-js": ["../packages/hasura-storage-js/src/index.ts"],
"@nhost/nextjs": ["../packages/nextjs/src/index.ts"],
"@nhost/nhost-js": ["../packages/nhost-js/src/index.ts"],
"@nhost/react": ["../packages/react/src/index.ts"],
"@nhost/react-apollo": ["../packages/react-apollo/src/index.ts"],
"@nhost/react-auth": ["../packages/react-auth/src/index.ts"]
}
},
"exclude": [
"node_modules",
"**/*/dist",
"**/*/build",
"**/*/.next",
"**/*/__tests__",
"**/*/__mocks__"
]
}

71
config/vite.lib.config.js Normal file
View File

@@ -0,0 +1,71 @@
import fs from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import tsconfigPaths from 'vite-tsconfig-paths'
const PWD = process.env.PWD
const pkg = require(path.join(PWD, 'package.json'))
const tsEntry = path.resolve(PWD, 'src/index.ts')
const entry = fs.existsSync(tsEntry) ? tsEntry : tsEntry.replace('.ts', '.tsx')
const deps = [...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies))]
export default defineConfig({
optimizeDeps: {
include: ['react/jsx-runtime']
},
plugins: [
tsconfigPaths(),
dts({
exclude: ['**/*.spec.ts', '**/*.test.ts', '**/tests/**'],
afterBuild: () => {
const types = fs.readdirSync(path.join(PWD, 'dist/src'))
types.forEach((file) => {
fs.renameSync(path.join(PWD, 'dist/src', file), path.join(PWD, 'dist', file))
})
fs.rmdirSync(path.join(PWD, 'dist/src'))
}
})
],
test: {
globals: true,
environment: 'jsdom',
reporters: 'verbose',
include: [`${PWD}/src/**/*.{spec,test}.{ts,tsx}`, `${PWD}/tests/**/*.{spec,test}.{ts,tsx}`],
// Note: temporarily disabled threads, because of a bug in vitest
// https://github.com/vitest-dev/vitest/issues/1171
threads: false
},
build: {
sourcemap: true,
lib: {
entry,
name: pkg.name,
fileName: 'index',
formats: ['cjs', 'es']
},
rollupOptions: {
external: (id) => deps.some((dep) => id.startsWith(dep)),
output: {
globals: {
'graphql/language/printer': 'graphql/language/printer',
'@apollo/client': '@apollo/client',
'@apollo/client/link/context': '@apollo/client/link/context',
'@apollo/client/link/subscriptions': '@apollo/client/link/subscriptions',
'@apollo/client/utilities': '@apollo/client/utilities',
'graphql-ws': 'graphql-ws',
xstate: 'xstate',
axios: 'axios',
'js-cookie': 'Cookies',
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': '_jsx',
'@nhost/react': '@nhost/react'
}
}
}
}
})

View File

@@ -0,0 +1,13 @@
import { defineConfig } from 'vite'
import viteLibConfig from './vite.lib.config'
export default defineConfig({
...viteLibConfig,
build: {
...viteLibConfig.build,
watch: {
buildDelay: 500
}
}
})

View File

@@ -0,0 +1,42 @@
import fs from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import tsconfigPaths from 'vite-tsconfig-paths'
import baseLibConfig from './vite.lib.config'
const PWD = process.env.PWD
const pkg = require(path.join(PWD, 'package.json'))
const deps = [...Object.keys(Object.assign({}, pkg.peerDependencies))]
export default defineConfig({
plugins: [
tsconfigPaths(),
dts({
exclude: ['**/*.spec.ts', '**/*.test.ts', '**/tests/**'],
afterBuild: () => {
const types = fs.readdirSync(path.join(PWD, 'umd/src'))
types.forEach((file) => {
fs.renameSync(path.join(PWD, 'umd/src', file), path.join(PWD, 'umd', file))
})
fs.rmdirSync(path.join(PWD, 'umd/src'))
}
})
],
build: {
...(baseLibConfig.build || {}),
outDir: 'umd',
lib: {
...(baseLibConfig.build?.lib || {}),
fileName: pkg.name.replace(/@nhost\//g, ''),
formats: ['umd']
},
rollupOptions: {
...(baseLibConfig.build?.rollupOptions || {}),
external: (id) => deps.some((dep) => id.startsWith(dep))
}
}
})

View File

@@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import baseLibConfig from './vite.lib.config'
export default defineConfig({
...baseLibConfig,
plugins: [react(), ...baseLibConfig.plugins]
})

View File

@@ -0,0 +1,13 @@
import { defineConfig } from 'vite'
import viteReactConfig from './vite.react.config'
export default defineConfig({
...viteReactConfig,
build: {
...viteReactConfig.build,
watch: {
buildDelay: 500
}
}
})

View File

@@ -0,0 +1,45 @@
import fs from 'fs'
import path from 'path'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import tsconfigPaths from 'vite-tsconfig-paths'
import react from '@vitejs/plugin-react'
import baseLibConfig from './vite.lib.config'
const PWD = process.env.PWD
const pkg = require(path.join(PWD, 'package.json'))
const deps = [...Object.keys(Object.assign({}, pkg.peerDependencies))]
export default defineConfig({
plugins: [
react(),
tsconfigPaths(),
dts({
exclude: ['**/*.spec.ts', '**/*.test.ts', '**/tests/**'],
afterBuild: () => {
const types = fs.readdirSync(path.join(PWD, 'umd/src'))
types.forEach((file) => {
fs.renameSync(path.join(PWD, 'umd/src', file), path.join(PWD, 'umd', file))
})
fs.rmdirSync(path.join(PWD, 'umd/src'))
}
})
],
build: {
...(baseLibConfig.build || {}),
outDir: 'umd',
lib: {
...(baseLibConfig.build?.lib || {}),
fileName: pkg.name.replace(/@nhost\//g, ''),
formats: ['umd']
},
rollupOptions: {
...(baseLibConfig.build?.rollupOptions || {}),
external: (id) => deps.some((dep) => id.startsWith(dep))
}
}
})

View File

@@ -1,11 +0,0 @@
{
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"endOfLine": "auto",
"semi": true
}

9
docs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,9 @@
# @nhost/docs
## 0.0.1
### Patch Changes
- 584976d: - publishable directory structure changes (ESM, CJS and UMD included in the output)
- build system improvements
- fixed some bundling concerns (https://github.com/nhost/nhost/issues/428)

View File

@@ -3,7 +3,7 @@ title: 'Authenticate users'
slug: /get-started/authentication
---
You defined `select` permissions for the `public` role in the previous section. You will now add `insert` and `create` permissions for authenticated users to secure your app's GraphQL API with authentication.
In the previous section, you defined `select` permissions for the `public` role. You will now add `insert` and `select` permissions for authenticated users to secure your app's GraphQL API with authentication.
> Nhost's authentication service lets you deliver frictionless registration and login experiences to your users. We support most social providers and different methods such as email & password and passwordless (magic link).
@@ -13,13 +13,15 @@ You defined `select` permissions for the `public` role in the previous section.
Manually create a user by going to your app's **Users** tab (top menu) and clicking on **Add User**.
![Add user](/img/quick-start/add-user.gif)
<video width="99%" loop="" muted="" playsInline="" controls="true">
<source src="/videos/add-user.mp4" type="video/mp4" />
</video>
You will now use that newly created user to make authenticated requests to the API.
You will now use that newly created user. We'll use this newly created user to make authenticated requests to the GraphQL API.
---
## Authenticate and query data
## Sign in and query data
Add the following code to sign in the new user and request the list of todos again:
@@ -60,9 +62,41 @@ Why is the return value `null`? Because when making GraphQL requests as an authe
> For authenticated requests, there is always the option to override the default `user` role with any other valid role.
---
To prepare our database and GraphQL API to work for signed-in users we need to do two things:
## Permissions for users
1. Add a `user_id` column to the `todos` table, so we know what todo belongs to which user.
2. Use the `user` role instead of the `public` role for permissions.
## Add `user_id` column
Before adding the `user_id` column, let's delete all existing todos.
Then add the `user_id` column as a `UUID` type. Make sure that `nullable` is **not** checked. This will ensure that all todos must have a `user_id` value.
At last, we'll create a connection between the `todos` table and the `users` table. For that, we need to do yet another two things:
1. Create a Foreign Key (FK) between `todos` and `auth.users.id`.
2. Let Hasura track the relationship between the two tables.
<video width="99%" loop="" muted="" playsInline="" controls="true">
<source src="/videos/user-id-column.mp4" type="video/mp4" />
</video>
### Create FK
Create a FK between the `auth.users.id` column and the `public.todos.user_id` column. See video above.
### Track relationship
Click on the `public` schema and track the untracked foreign key relationship. Then click on the `auth` schema and track the relationship again. See video above.
We track these relationships to create the GrpahQL relationships between the `todos` table to the `users` table and the `users` table to the `todos` table.
Ok, our `user_id` column is added and connected correctly. Let's continue with setting permissions for signed-in users.
## Permissions for signed-in users
Let us organize the permissions so it works for signed in users too.
### Remove permissions for the public role
@@ -72,7 +106,7 @@ We won't use the `public` role anymore, so let's remove all permission for that
Now we'll add permissions for the `user` role.
> All logged-in users have the `user` role.
> Signed-in users use the `user` role by default
### Insert permission

View File

@@ -30,7 +30,7 @@ Create a new folder called `nhost-todos`, initialize a new JavaScript app there,
```bash
npm init -y
yarn add @nhost/nhost-js graphql
npm install @nhost/nhost-js graphql
```
</TabItem>
@@ -38,7 +38,7 @@ yarn add @nhost/nhost-js graphql
```bash
yarn init -y
npm install @nhost/nhost-js graphql
yarn add @nhost/nhost-js graphql
```
</TabItem>

View File

@@ -65,7 +65,9 @@ This is all we need! A new table will be created when you click **Add Table**.
Go to the **Insert Row** tab to add some data to your database.
![Inserting todos](/img/quick-start/insert-todos.gif)
<video width="99%" loop="" muted="" playsInline="" controls="true">
<source src="/videos/insert-todos.mp4" type="video/mp4" />
</video>
---

View File

@@ -1,5 +0,0 @@
{
"label": "The Nhost Platform",
"position": 1,
"link": { "type": "generated-index", "slug": "/platform" }
}

View File

@@ -1,5 +1,4 @@
{
"label": "Authentication",
"position": 4,
"link": { "id": "platform/authentication/index", "type": "doc" }
"position": 6
}

View File

@@ -9,7 +9,7 @@ Nhost provides a ready-to-use authentication service, integrated with Nhost Java
## Getting Started
Sign up a user with the [Nhost JavaScript SDK](/reference/sdk):
Sign up a user with the [Nhost JavaScript SDK](/reference/javascript):
```js
import { NhostClient } from '@nhost/nhost-js';
@@ -48,7 +48,7 @@ query {
Nhost authentication uses two tokens: Access tokens and refresh tokens.
[Nhost JavaScript SDK](/reference/sdk) automatically handles access and refresh tokens.
[Nhost JavaScript SDK](/reference/javascript) automatically handles access and refresh tokens.
### Access tokens

View File

@@ -58,7 +58,7 @@ To make sure we can fetch all user data (email, profile picture and name). For t
## Sign In users in your app
Use the [Nhost JavaScript client](/reference/sdk) to sign in users in your app:
Use the [Nhost JavaScript client](/reference/javascript) to sign in users in your app:
```js
nhost.auth.signIn({

View File

@@ -43,7 +43,7 @@ Follow this guide to sign in users with GitHub with your Nhost App.
## Sign In users in your app
Use the [Nhost JavaScript client](/reference/sdk) to sign in users in your app:
Use the [Nhost JavaScript client](/reference/javascript) to sign in users in your app:
```js
nhost.auth.signIn({

View File

@@ -23,7 +23,7 @@ You need to set client ID and client secret for each provider that you want to e
## Implementing sign-in experience
Use the [Nhost JavaScript SDK](/reference/sdk) and the `signIn()` method to implement social sign-in in your app,
Use the [Nhost JavaScript SDK](/reference/javascript) and the `signIn()` method to implement social sign-in in your app,
Here's an example of how to implement sign-in with GitHub:

View File

@@ -50,7 +50,7 @@ Follow this guide to sign in users with LinkedIn with your Nhost App.
## Sign In users in your app
Use the [Nhost JavaScript client](/reference/sdk) to sign in users in your app:
Use the [Nhost JavaScript client](/reference/javascript) to sign in users in your app:
```js
nhost.auth.signIn({

View File

@@ -43,7 +43,7 @@ Follow this guide to sign in users with Spotify with your Nhost App.
## Sign In users in your app
Use the [Nhost JavaScript client](/reference/sdk) to sign in users in your app:
Use the [Nhost JavaScript client](/reference/javascript) to sign in users in your app:
```js
nhost.auth.signIn({

View File

@@ -17,6 +17,7 @@ query {
id
displayName
email
metadata
}
}
```
@@ -29,6 +30,7 @@ query {
id
displayName
email
metadata
}
}
```
@@ -85,3 +87,8 @@ await nhost.graphql.request(
```
If the request is not part of the user's roles, the request will fail.
---
## Metadata
Custom additional user information stored in the `metadata` column. Can be any JSON object.

View File

@@ -0,0 +1,80 @@
---
title: 'CLI'
sidebar_position: 11
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Nhost CLI, or `nhost`, is a command-line interface that lets you run and manage Nhost apps locally on Mac, Linux and Windows (WSL2).
This means you get a full-featured Nhost app running locally on your machine:
- Postgres Database
- Hasura GraphQL API
- Hasura Console
- Auth
- Storage
- Serverless Functions
This way, you can develop and test local changes before you deploy them live. The CLI automatically tracks:
- Postgres database migrations
- Hasura metadata
- Serverless functions
It's recommended to commit and push changes to GitHub and use the [GitHub integration](/platform/github-integration) for Nhost to automatically deploy those changes live.
## Installation
To download and install Nhost CLI, run the following command:
```bash
sudo curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | bash
```
### Dependencies
The following dependencies are required:
- [Git](https://git-scm.com/downloads)
- [Docker](https://www.docker.com/get-started) (must be running while using the CLI)
## Get started
Start by authenticating yourself to Nhost Cloud:
```
nhost login
```
Once signed in, you can list all your Nhost apps using:
```
nhost list
```
Let's start by initializing a remote Nhost app locally with the following command:
```
nhost init --remote
```
Pick a Nhost app to use then change the directory once the app initialization is completed:
```
cd my_test_app
```
Then start the Nhost app locally:
```
nhost up
```
Hasura Console starts automatically and your Nhost app is running locally with the backend URL: `http://localhost:1337`.
## What's next?
- Read our in-depth guide on [Get started with Nhost CLI](/platform/overview/get-started-with-nhost-cli)
- [CLI commands reference](/reference/cli)

View File

@@ -1,4 +1,4 @@
{
"label": "Database",
"position": 2
"position": 4
}

View File

@@ -15,7 +15,7 @@ Event triggers are managed in Hasura. Go to Hasura, then select **Events** in th
![Creating event trigger in Hasura](/img/platform/hasura-create-event-trigger.png)
Nhost's [environment variables](/platform/nhost/environment-variables) can be used in event trigger headers. For example, you can attach `NHOST_WEBHOOK_SECRET` to an outgoing webhook here.
Nhost's [environment variables](/platform/environment-variables) can be used in event trigger headers. For example, you can attach `NHOST_WEBHOOK_SECRET` to an outgoing webhook here.
---
@@ -29,6 +29,10 @@ https://[app-subdomain].nhost.run/v1/functions/my-endpoint
The environment variable `NHOST_BACKEND_URL` will have the correct value.
```bash
{{NHOST_BACKEND_URL}}/v1/functions/my-endpoint
```
---
## Security
@@ -39,7 +43,7 @@ In your serverless function, you need to make sure the request actually comes fr
- Check the header in the serverless function. It should match the environment variable `NHOST_WEBHOOK_SECRET`.
```js
export default function async handler(req, res) {
export default async function handler(req, res) {
// Check webhook secret to make sure the request is valid
if (

View File

@@ -1,6 +1,6 @@
---
title: 'Environment variables'
sidebar_position: 1
sidebar_position: 9
---
Environment variables are key-value pairs configured outside your source code. They are used to store environment-specific values such as API keys.

View File

@@ -1,6 +1,6 @@
---
title: 'GitHub integration'
sidebar_position: 2
sidebar_position: 10
---
You can connect your Nhost app to a GitHub repository. When you do this, any updates you push to your code will automatically be deployed.
@@ -21,7 +21,7 @@ Specifically, the following will be deployed:
## Workflow
Create a new Nhost app. Then use [Nhost CLI](/platform/nhost/local-development) to initialize your Nhost app locally.
Create a new Nhost app. Then use [Nhost CLI](/platform/cli) to initialize your Nhost app locally.
The workflow is as follows:

View File

@@ -1,4 +1,4 @@
{
"label": "GraphQL",
"position": 3
"position": 5
}

View File

@@ -20,7 +20,7 @@ To interact with the GraphQL API it's recommended to use a GraphQL client:
- [React Query](https://react-query.tanstack.com/graphql)
- [SWR](https://swr.vercel.app/docs/data-fetching#graphql)
It's also possible to use the built-in [GraphQL client](/reference/sdk/graphql) in the Nhost JavaScript client.
It's also possible to use the built-in [GraphQL client](/reference/javascript/nhost-js/graphql) in the Nhost JavaScript client.
---

View File

@@ -1,11 +0,0 @@
---
title: 'The Nhost Platform'
sidebar_position: 1
---
- [Database](/platform/database)
- [GraphQL](/platform/graphql)
- [Authentication](/platform/authentication)
- [Storage](/platform/storage)
- [Serverless Functions](/platform/serverless-functions)
- [Nhost](/platform/nhost)

View File

@@ -0,0 +1,28 @@
---
title: 'Introduction to Nhost'
sidebar_label: Introduction
sidebar_position: 1
---
Nhost is the open source GraphQL backend (Firebase Alternative) and a development platform. Nhost is doing for the backend, what [Netlify](https://netlify.com/) and [Vercel](https://vercel.com/) are doing for the frontend.
We provide a modern backend with the general building blocks required to build fantastic digital products.
We make it easy to build and deploy this backend using our platform that takes care of configuration, security, and performance. Things just works and scale automatically so you can focus on your product and on your business.
## Quickstart
Get started quickly by following one of our quickstart guides:
- [Next.js](/platform/quickstarts/nextjs)
- [React](/platform/quickstarts/react)
## Products and features
Learn more about the product and features of Nhost.
- [Database](/platform/database)
- [GraphQL](/platform/graphql)
- [Authentication](/platform/authentication)
- [Storage](/platform/storage)
- [Serverless Functions](/platform/serverless-functions)

View File

@@ -1,4 +0,0 @@
{
"label": "Nhost",
"position": 7
}

View File

@@ -1,9 +0,0 @@
---
title: 'Overview'
---
Documentation for other platform features:
- [Environment variables](/platform/nhost/environment-variables)
- [GitHub integration](/platform/nhost/github-integration)
- [Local development](/platform/nhost/local-development)

View File

@@ -1,88 +0,0 @@
---
title: 'Nhost CLI'
sidebar_position: 3
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Nhost CLI lets you run Nhost's development environment locally on macOS, Linux and Windows.
---
## Installation
Download and install Nhost CLI for your platform by running this command in your terminal:
```bash
sudo curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | bash
```
### Dependencies
- [Git](https://git-scm.com/downloads) must be installed on your system
- [Docker](https://www.docker.com/get-started) must be installed and running when using Nhost CLI
### Function runtimes
To run serverless functions locally, you must have the appropriate runtimes installed on your machine:
- JavaScript and TypeScript functions: `Node.js 14.*`
For Node.js, you will also need to have [express](https://www.npmjs.com/package/express) installed in your repository:
<Tabs>
<TabItem value="npm" label="npm" default>
```bash
npm install --save-dev express @types/express
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add -D express @types/express
```
</TabItem>
</Tabs>
[Read more about runtimes](/platform/serverless-functions)
---
## Windows support
If you have Windows Subsystem for Linux and `curl` in your Windows environment, you run the command following the instructions above. It will download the `.exe` binary to your current working directory.
If you do not have the above dependencies, download and install the latest release manually from [GitHub releases](https://github.com/nhost/cli/releases).
---
## Apple silicon (M1)
As of late 2021, Hasura does not yet have an M1 optimized version for their GraphQL engine, which Nhost depends on.
If you have a MacBook with an M1 chip, the CLI will automatically change the image used in `nhost/config.yaml` of your app:
```yml
services:
hasura:
image: fedormelexin/graphql-engine-arm64
```
This will run the Hasura GraphQL engine using Rosetta on your machine until an M1 optimized image is launched.
---
## Upgrading
If you already Nhost CLI installed, you can upgrade your installation:
```bash
# sudo permissions needed
sudo nhost upgrade
```
The `upgrade` command was added in `0.5.0`.

View File

@@ -0,0 +1,5 @@
{
"label": "Overview",
"position": 2,
"collapsed": false
}

View File

@@ -0,0 +1,29 @@
---
title: 'Architecture'
sidebar_position: 2
---
Nhost is a backend as a service built with open source tools to provide developers the general building blocks required to build fantastic digital apps and products.
Here's a diagram of the Nhost stack on a high level:
![Nhost Architecture Diagram](/img/architecture/nhost-diagram.png)
As you see in the image above, Nhost provides endpoints for:
- GraphQL (`/graphql`)
- Authentication (`/auth`)
- Storage (`/storage`)
- Functions (`/functions`)
Data is stored in Postgres and files are stored in S3.
## Open Source
The open source tools used for the full Nhost stack are:
- Database: [Postgres](https://www.postgresql.org/)
- GraphQL: [Hasura](https://github.com/hasura/graphql-engine)
- Authentication: [Hasura Auth](https://github.com/nhost/hasura-auth)
- Storage: [Hasura Storage](https://github.com/nhost/hasura-storage)
- Functions: [Node.js](https://nodejs.org/en/)

View File

@@ -0,0 +1,438 @@
---
title: 'Get Started with Nhost CLI'
sidebar_position: 2
---
# Get started with Nhost CLI
Nhost's command-line interface (CLI) lets you run a complete Nhost development
environment locally with the following services: PostgreSQL database, Hasura,
Authentication, Storage (MinIO), Serverless Functions, and Emails (Mailhog).
## Installation
### Install the binary globally
To install **Nhost CLI**, run this command from any directory in your terminal:
```bash
sudo curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | bash
```
On **MacOS and Linux**, this will install the **Nhost CLI** in `/usr/local/bin`.
If you'd prefer to install to a different location other than `/usr/local/bin`,
set the `INSTALL_PATH` variable accordingly:
```bash
sudo curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | INSTALL_PATH=$HOME/bin bash
```
On **Windows**, this will download and extract the binary `nhost.exe` available
under `Assets` of the latest release from the GitHub release page:
https://github.com/nhost/cli/releases.
You can move the executable to a different location and add the path to the
environment variable `PATH` to make `nhost` accessible globally.
Finally, you can check that everything has been successfully installed by
typing:
```bash
nhost version
```
![Nhost CLI Version](/img/architecture/cli/cli-installed.png)
### (Optional) Add shell completion
To add command auto-completion in the shell, you can run the following command:
```bash
nhost completion [shell]
```
This will generate the autocompletion script for `nhost` for the specified shell
(bash, fish, PowerShell, or zsh).
## Prerequisites
### Dependencies
Before using the **Nhost CLI**, make sure you have the following dependencies
installed on your local machine:
- [Git](https://git-scm.com/downloads)
- [Docker](https://www.docker.com/get-started)
:::caution
Docker must be running while using Nhost CLI.
:::
### Nhost CLI login
After installing **Nhost CLI**, you can log in to your Nhost account by running
the following command:
```bash
nhost login
```
This will display a prompt for you to enter your Nhost account credentials
(email/password).
:::info
You can create a Nhost account here: [https://app.nhost.io](https://app.nhost.io/).
:::
![Nhost CLI Login](/img/architecture/cli/cli-login.png)
After successfully logging in, you are authorized to manage your Nhost projects
using the Nhost CLI.
You can also log out at any time by running:
```bash
nhost logout
```
## Set up your project
### 1. Create a new Nhost app
First things first, we need to create a new Nhost project.
So, log in to your Nhost dashboard and click the **Create your first app**
button.
![Nhost Create App](/img/architecture/cli/create-app-step-1.png)
Next, give your new Nhost app a name, select a geographic region for your Nhost
services and click **Create App**.
![Nhost Create App](/img/architecture/cli/create-app-step-2.png)
After a few seconds, you should get a PostgreSQL database, a GraphQL API with
Hasura, file storage, and authentication set up.
### 2. Create a new GitHub Repository
A typical workflow would also include creating a Github repository for your
Nhost project. It will facilitate your development workflow since Nhost can
integrate with Github to enable continuous deployment.
So, go to your Github account and
[create a new repository](https://github.com/new). You can make your repository
either public or private.
![Create GitHub Repo](/img/architecture/cli/create-github-repo.png)
### 3. Connect Nhost project to Github
Finally, connect your Github repository to your Nhost project. Doing so will
enable Nhost to deploy new versions of your project when you push automatically
commits to your connected Git repository.
1. From your project workspace, click **Connect to Github**.
![Connect to GitHub](/img/architecture/cli/connect-repo-step-1.png)
2. **Install the Nhost app** on your Github account.
![Connect to GitHub](/img/architecture/cli/connect-repo-step-2.png)
3. **Connect** your Github repository.
![Connect to GitHub](/img/architecture/cli/connect-repo-step-3.png)
## Develop locally
## 1. Initialize your Nhost app
**Nhost CLI** brings the functionality of your Nhost production environment
directly to your local machine.
It provides Docker containers to run the backend services that match your
production application in a local environment. That way, you can make changes
and test your code locally before deploying those changes to production.
You can either initialize a blank Nhost app locally to start from scratch by
running the following command:
```bash
nhost init -n my-nhost-app
```
And then link it to a remote app from your Nhost workspace in `app.nhost.io` by
running the `link` command and selecting the corresponding app from the prompt:
```bash
nhost link
```
Or you can directly initialize a local Nhost app from one of your existing
production apps by specifying the `--remote` flag:
```bash
nhost init --remote -n my-nhost-app
```
It will also prompt you to choose the remote app you'd like to use to initialize
your local Nhost development environment.
![Select app](/img/architecture/cli/cli-select-app.png)
The `init` command creates the Nhost app inside your current working directory
within a `nhost/` folder.
```
my-nhost-app/
└─ nhost/
├─ config.yaml
├─ emails/
├─ metadata/
├─ migrations/
└─ seeds/
```
Finally, make sure to link your current working directory to your GitHub
repository:
```bash
echo "# my-nhost-app" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/[github-username]/my-nhost-app.git
git push -u origin main
```
## 2. Start a local development environment
To start a local development environment for your Nhost app, run the following
command:
```bash
nhost dev
```
:::caution
Make sure [Docker](https://www.docker.com/get-started) is up and running. Its required for Nhost to work.
:::
Running this command will start up all the backend services provided by Nhost.
It also runs a webserver to serve the Hasura console for the GraphQL engine so
you can manage the database and try out the API.
The Hasura console should open automatically at
[http://localhost:1337](http://localhost:1337/).
![Hasura Console](/img/architecture/cli/hasura-console.png)
## 3. Make changes
There are three things the Nhost CLI and the GitHub integration track and apply
to production:
- Database migrations
- Hasura Metadata
- Serverless Functions
:::caution
Settings in `nhost/config.yaml` are not being applied to production. They only work locally for now.
:::
### Database migrations
Database changes are tracked and managed through migrations.
:::tip
It's important that you use the Hasura console to make database changes. Indeed, with the Hasura console, DB migration files are generated incrementally to track changes automatically for you.
:::
To demonstrate how to make database changes, let's create a new table called
`messages`, with the following columns:
- `id` (type UUID and default `gen_random_uuid()`),
- `text` (type Text),
- `authorId` (type UUID),
- `createdAt` (type Timestamp and default `now()`)
In the Hasura console, head over to the **data** tab section and click on the
PostgreSQL database (from the left side navigation) that Nhost provides us.
Click on the **public** schema and the **Create Table** button.
![Create Table](/img/architecture/cli/create-table-step-1.png)
Then, enter the values for creating the `messages` table as mentioned above.
Also, specify the `id` column as the primary key of the table, and link the
`authorId` column to the `users.id` column using a foreign key to link the
`users` and `messages` tables together.
![Create Table](/img/architecture/cli/create-table-step-2.png)
Next, click on the **Add Table** button to create the table.
Finally, check out the `migrations/` folder in your project directory. A
migration file has been created automatically to reflect our database changes
and track the new table creation.
The migration was created under `nhost/migrations/default`:
```bash
$ ls -la nhost/migrations/default
total 0
drwxr-xr-x 3 user staff 96 Apr 27 17:06 .
drwxr-xr-x 3 user staff 96 Apr 27 17:06 ..
drwxr-xr-x 4 user staff 128 Apr 27 17:06 1651071963431_create_table_public_messages
```
However, note that this database migration has only been applied locally. In
other words, the `messages` table does not (yet) exists in production.
To apply the local changes to production, check out the
[Deploy your project](#deploy-your-project) section below.
### Hasura metadata
In addition to database schema changes, Nhost also tracks Hasura metadata.
The Hasura metadata track all the actions performed on the console, like
tracking tables/views/functions, creating relationships, configuring
permissions, creating event triggers, and remote schemas.
To demonstrate it, let's add a new permission to our `messages` table for the
`user` role on the `insert` operation. That permission will allow users to
create new messages.
So, open the permissions tab for the `messages` table, type in `user` in the
role cell, and click the edit icon on the `insert` operation:
![Create Table](/img/architecture/cli/permissions-1.png)
To restrict the users to create new messages only for themselves, specify an
`_eq` condition between the `authorId` and the `X-Hasura-User-ID` session
variable, which is passed with each request.
![Create Table](/img/architecture/cli/permissions-2.png)
Then, select the columns the users can define through the GraphQL API, set the
value for the `authorId` column to be equal to the `X-Hasura-User-ID` session
variable, and click **Save Permissions**.
![Create Table](/img/architecture/cli/permissions-3.png)
Finally, check out the `metadata/` folder in your project directory to confirm
that the permission changes we did were tracked locally in your git repository.
In our case, those changes should be tracked in
`nhost/metadata/databases/default/tables/public_messages.yaml`:
```yaml title="nhost/metadata/databases/default/tables/public_messages.yaml"
table:
name: messages
schema: public
insert_permissions:
- permission:
backend_only: false
check:
authorId:
_eq: X-Hasura-User-Id
columns:
- text
set:
authorId: x-hasura-User-Id
role: user
```
### Serverless functions
Now let's create a serverless function before we push all changes to GitHub so
Nhost can deploy them to production.
For this guide, let's create a simple serverless function that will return the
current date-time when called.
First, make sure to install `express`, which is required for serverless
functions to work.
```bash
npm install express
npm install -d @types/node @types/express
```
Then, create a new file named `time.ts` inside the `functions/` folder of your
working directory, and paste the following code:
```ts title="functions/time.ts"
import { Request, Response } from 'express';
export default (req: Request, res: Response) => {
return res
.status(200)
.send(`Hello ${req.query.name}! It's now: ${new Date().toUTCString()}`);
};
```
Every JavaScript and TypeScript file inside the `functions/` folder becomes an
API endpoint.
Locally, the base URL for the serverless functions is
`http://localhost:1337/v1/functions`. Then, the endpoint for each function is
determined by its filename or the name of its dedicated parent directory.
For example, the endpoint for our function is
`http://localhost:1337/v1/functions/time`.
```bash
curl http://localhost:1337/v1/functions/time\?name\=Greg
Hello Greg! It's now: Wed, 27 Apr 2022 18:52:12 GMT
```
## Deploy your project
To deploy your local changes to production, you can commit and push them to
GitHub. As a result, Nhost will automatically pick up the changes in your
repository and apply them to your associated remote Nhost project.
:::caution
Make sure to [connect your Github repository](#3-connect-nhost-project-to-Github) to your Nhost project first.
:::
```bash
git add -A
git commit -m "commit message"
git push
```
To check out your deployment, head over to the **Deployments** tab in your
[Nhost dashboard](https://app.nhost.io).
![Deployments](/img/architecture/cli/deployments.png)
## Get help
To get usage tips and learn more about available commands from within Nhost CLI,
run the following:
```shell
nhost help
```
For more information about a specific command, run the command with the `--help`
flag:
```
nhost init --help
```
If you have additional questions or ideas for new features, you can
[start an issue](https://github.com/nhost/cli/issues) or
[a new discussion](https://github.com/nhost/cli/discussions/new) on Nhost CLIs
open-source repository. You can also
[chat with our team](https://discord.com/invite/9V7Qb2U) on Discord.
Wed love to hear from you!

View File

@@ -0,0 +1,5 @@
{
"label": "Quickstarts",
"position": 3,
"collapsed": false
}

View File

@@ -0,0 +1,744 @@
---
title: 'Quickstart: Next.js'
sidebar_position: 2
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Quickstart: Next.js
## Introduction
This quickstart guide provides the steps you need to build a simple Next.js app
powered by Nhost for the backend. It includes:
- Database: [PostgreSQL](https://www.postgresql.org/)
- Instant GraphQL API: [Hasura](https://hasura.io/)
- Authentication: [Hasura Auth](https://github.com/nhost/hasura-auth/)
- Storage: [Hasura Storage](https://hub.docker.com/r/nhost/hasura-storage)
By the end of this guide, you'll have a full-stack app that allows users to log
in to access a protected dashboard and update their profile information.
## Prerequisites
Before getting started, let's make sure that your development environment is
ready.
You'll need **Node.js** version 12 or later: [install it from here](https://nodejs.org/en/).
## Project setup
### Create a new Nhost app
First things first, we need to create a new Nhost project.
So, log in to your Nhost dashboard and click the **Create your first app**
button.
![nhost-first-app](/img/quickstarts/create-app-step-1.png)
Next, give your new Nhost app a name, select a geographic region for your Nhost
services and click **Create App**.
![nhost-first-app](/img/quickstarts/create-app-step-2.png)
After a few seconds, you should get a PostgreSQL database, a GraphQL API with
Hasura, file storage, and authentication set up.
:::info
You can also connect your Nhost app to a GitHub repository. When you do this, any updates you push to your code will automatically be deployed. [Learn more](https://docs.nhost.io/platform/github-integration).
:::
## Initialize the app
### Create a Next.js app
The simplest way to create a new Next.js application is by using the tool called
`create-next-app`, which bootstraps a Next.js app for you without the hassle of
configuring everything yourself.
So, open your terminal, and run the following command:
```bash
npx create-next-app my-nhost-app --example "https://github.com/nhost/quickstart-nextjs"
```
:::info
This command uses an [existing template](https://github.com/nhost/quickstart-nextjs), through the `--example` flag, which already contains the React components and pages we'll use for this guide.
:::
You can now `cd` into your project directory:
```bash
cd my-nhost-app
```
And run the development server with the following command:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm" default>
```bash
npm run dev
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn dev
```
</TabItem>
</Tabs>
If everything is working fine, your Next.js development server should be running
on port 3000. Open [http://localhost:3000](http://localhost:3000) from your
browser to check this out.
### Configure Nhost with Next.js
To work with Nhost from within our Next.js app, we'll use the
[Next.js SDK](https://github.com/nhost/nhost/tree/main/packages/nextjs) provided
by Nhost. It's a wrapper around the
[Nhost React SDK](https://github.com/nhost/nhost/tree/main/packages/react) which
gives us a way to interact with our Nhost backend using React hooks.
You can install the Nhost Next.js SDK with:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm" default>
```bash
npm install @nhost/react @nhost/nextjs graphql
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add @nhost/react @nhost/nextjs graphql
```
</TabItem>
</Tabs>
Next, open your `_app.js` file as we'll now configure Nhost inside our app.
The Nhost Next.js SDK comes with a React provider named `NhostNextProvider` that
makes the authentication state and all the provided React hooks available in our
application.
Use the following code to instantiate a new Nhost client and link it to your
Nhost backend:
```jsx title="pages/_app.js"
import { UserProvider } from '../UserProvider';
// highlight-start
import { NhostNextProvider, NhostClient } from '@nhost/nextjs';
// highlight-end
// highlight-start
const nhost = new NhostClient({
backendUrl: process.env.NEXT_PUBLIC_NHOST_BACKEND_URL || '',
});
// highlight-end
function MyApp({ Component, pageProps }) {
return (
{/* highlight-next-line */}
<NhostNextProvider nhost={nhost} initial={pageProps.nhostSession}>
<UserProvider>
{/* ... */}
</UserProvider>
{/* highlight-next-line */}
</NhostNextProvider>
);
}
```
Finally, make sure to create an environment variable named
`NEXT_PUBLIC_NHOST_BACKEND_URL` to store your Nhost backend URL:
```yaml title=".env.development"
NEXT_PUBLIC_NHOST_BACKEND_URL=YOUR_NHOST_BACKEND_URL
```
You can find your Nhost backend URL for your project from [your dashboard](https://app.nhost.io) as shown below:
![Nhost Backend URL](/img/quickstarts/app-dashboard.png)
:::caution
Don't forget to restart your Next.js server after saving your `.env.development`
file to load your new environment variable.
:::
## Build the app
### Add authentication
#### 1. Sign-up
The next step is to allow our users to authenticate into our application.
Let's start with implementing the sign-up process.
For that, we'll use the `useSignUpEmailPassword` hook provided by the Nhost
Next.js SDK within our `SignUp` component.
So, open up the corresponding file from your project, and use the following
code:
```jsx title="components/SignUp.js"
import styles from '../styles/components/SignUp.module.css';
import { useState } from 'react';
import { useRouter } from 'next/router';
import { useSignUpEmailPassword } from '@nhost/nextjs';
import Link from 'next/link';
import Image from 'next/image';
import Input from './Input';
import Spinner from './Spinner';
const SignUp = () => {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const router = useRouter();
const {
signUpEmailPassword,
isLoading,
isSuccess,
needsEmailVerification,
isError,
error,
} = useSignUpEmailPassword();
const handleOnSubmit = async (e) => {
e.preventDefault();
await signUpEmailPassword(email, password, {
displayName: `${firstName} ${lastName}`.trim(),
metadata: {
firstName,
lastName,
},
});
};
if (isSuccess) {
router.push('/');
return null;
}
const disableForm = isLoading || needsEmailVerification;
return (
<div className={styles.container}>
<div className={styles.card}>
<div className={styles['logo-wrapper']}>
<Image src="/logo.svg" alt="logo" layout="fill" objectFit="contain" />
</div>
{needsEmailVerification ? (
<p className={styles['verification-text']}>
Please check your mailbox and follow the verification link to verify
your email.
</p>
) : (
<form onSubmit={handleOnSubmit} className={styles.form}>
<div className={styles['input-group']}>
<Input
label="First name"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
disabled={disableForm}
required
/>
<Input
label="Last name"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
disabled={disableForm}
required
/>
</div>
<Input
type="email"
label="Email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={disableForm}
required
/>
<Input
type="password"
label="Create password"
value={password}
onChange={(e) => setPassword(e.target.value)}
disabled={disableForm}
required
/>
<button
type="submit"
disabled={disableForm}
className={styles.button}
>
{isLoading ? <Spinner size="sm" /> : 'Create account'}
</button>
{isError ? (
<p className={styles['error-text']}>{error?.message}</p>
) : null}
</form>
)}
</div>
<p className={styles.text}>
Already have an account?{' '}
<Link href="/sign-in">
<a className={styles.link}>Sign in</a>
</Link>
</p>
</div>
);
};
export default SignUp;
```
By default, the user must verify his email address before fully signing up. You can change this setting from your Nhost dashboard.
#### 2. Sign-in
Now that new users can sign up for our application, let's see how to allow
existing users to sign in with email and password.
For that, we will use the Nhost hook named `useSignInEmailPassword` inside our
`SignIn` component the same way we did with our `SignUp` component. So, here's
what your component should look like after applying the changes for the sign-in
logic:
```jsx title="components/SignIn.js"
import styles from '../styles/components/SignIn.module.css';
import { useState } from 'react';
import { useRouter } from 'next/router';
import { useSignInEmailPassword } from '@nhost/nextjs';
import Link from 'next/link';
import Image from 'next/image';
import Input from './Input';
import Spinner from './Spinner';
const SignIn = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const router = useRouter();
const {
signInEmailPassword,
isLoading,
isSuccess,
needsEmailVerification,
isError,
error,
} = useSignInEmailPassword();
const handleOnSubmit = async (e) => {
e.preventDefault();
await signInEmailPassword(email, password);
};
if (isSuccess) {
router.push('/');
return null;
}
const disableForm = isLoading || needsEmailVerification;
return (
<div className={styles.container}>
<div className={styles.card}>
<div className={styles['logo-wrapper']}>
<Image src="/logo.svg" alt="logo" layout="fill" objectFit="contain" />
</div>
{needsEmailVerification ? (
<p className={styles['verification-text']}>
Please check your mailbox and follow the verification link to verify
your email.
</p>
) : (
<>
<form onSubmit={handleOnSubmit} className={styles.form}>
<Input
type="email"
label="Email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={disableForm}
required
/>
<Input
type="password"
label="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
disabled={disableForm}
required
/>
<button
type="submit"
disabled={disableForm}
className={styles.button}
>
{isLoading ? <Spinner size="sm" /> : 'Sign in'}
</button>
{isError ? (
<p className={styles['error-text']}>{error?.message}</p>
) : null}
</form>
</>
)}
</div>
<p className={styles.text}>
No account yet?{' '}
<Link href="/sign-up">
<a className={styles.link}>Sign up</a>
</Link>
</p>
</div>
);
};
export default SignIn;
```
#### 3. Sign-out
Finally, to allow the users to sign out from the app, we can use the Nhost
`useSignOut` hook:
```jsx title="components/Layout.js"
import { useSignOut } from '@nhost/nextjs';
const Layout = ({ children = null }) => {
const { signOut } = useSignOut();
const menuItems = [
//..
{
label: 'Logout',
onClick: signOut,
icon: LogoutIcon,
},
];
//...
};
```
### Protect routes
Now that we have implemented authentication, we can easily decide who can access
certain parts of our application.
In our case, we'll only allow authenticated users to have access to the `/` and
`/profile` routes. All the other users should be redirected to the `/sign-in`
page if they try to access those routes.
To do so, we can check the authentication status of the current user using the
Nhost SDK by creating a
[high-order component](https://reactjs.org/docs/higher-order-components.html):
```jsx title="withAuth.js"
import styles from './styles/pages/ProtectedRoute.module.css';
import { useRouter } from 'next/router';
import { useAuthenticationStatus } from '@nhost/nextjs';
import Spinner from './components/Spinner';
export default function withAuth(Component) {
return function AuthProtected(props) {
const router = useRouter();
const { isLoading, isAuthenticated } = useAuthenticationStatus();
if (isLoading) {
return (
<div className={styles.container}>
<Spinner />
</div>
);
}
if (!isAuthenticated) {
router.push('/sign-in');
return null;
}
return <Component {...props} />;
};
}
```
Then, wrap our Next.js pages, `index.js` and `profile.js`, with it:
<Tabs
defaultValue="index"
values={[
{label: 'pages/index.js', value: 'index'},
{label: 'pages/profile.js', value: 'profile'},
]}>
<TabItem value="index">
```js
import withAuth from '../withAuth';
const Home = () => {
//...
};
export default withAuth(Home);
```
</TabItem>
<TabItem value="profile">
```js
import withAuth from '../withAuth';
const Profile = () => {
//...
};
export default withAuth(Profile);
```
</TabItem>
</Tabs>
### Retrieve user data
Finally, let's display the information of the authenticated user throughout his
dashboard to make the app more personalized.
Getting the current authenticated user data is quite easy. We
can use the `useUserData` hook provided by Nhost to do it.
So, open the `UserProvider.js` file and use this hook like so:
```js
import React, { useContext } from 'react';
// highlight-next-line
import { useUserData } from '@nhost/nextjs';
const UserContext = React.createContext(null);
export function UserProvider({ children = null }) {
// highlight-next-line
const user = useUserData();
return (
<UserContext.Provider value={{ user }}>{children}</UserContext.Provider>
);
}
export function useUserContext() {
return useContext(UserContext);
}
```
That's it! The JSX code for rendering the user data (email, display name, etc.)
is already included in your components as part of the example repository you've
bootstrapped at the beginning of this guide.
### Update user data
Nhost provides a GraphQL API through Hasura so that we can query and mutate our
data instantly.
In this tutorial, we'll use the
[Apollo GraphQL client](https://www.apollographql.com/) for interacting with
this GraphQL API.
So, start by installing the following dependencies:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm" default>
```bash
npm install @nhost/react-apollo @apollo/client
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add @nhost/react-apollo @apollo/client
```
</TabItem>
</Tabs>
Then, add the `NhostApolloProvider` from `@nhost/react-apollo` into your
`_app_.js` file.
```jsx title="pages/_app.js"
import { NhostApolloProvider } from '@nhost/react-apollo';
function MyApp({ Component, pageProps }) {
return (
<NhostNextProvider nhost={nhost} initial={pageProps.nhostSession}>
<NhostApolloProvider nhost={nhost}>{/* ... */}</NhostApolloProvider>
</NhostNextProvider>
);
}
```
From there, we can construct our GraphQL query and use the Apollo `useMutation`
hook to execute that query when the user submits the form from the profile page:
```js title="pages/profile.js"
import { gql, useMutation } from '@apollo/client';
import { toast } from 'react-hot-toast';
const UPDATE_USER_MUTATION = gql`
mutation ($id: uuid!, $displayName: String!, $metadata: jsonb) {
updateUser(
pk_columns: { id: $id }
_set: { displayName: $displayName, metadata: $metadata }
) {
id
displayName
metadata
}
}
`;
const Profile = () => {
const [mutateUser, { loading: updatingProfile }] =
useMutation(UPDATE_USER_MUTATION);
const updateUserProfile = async (e) => {
e.preventDefault();
try {
await mutateUser({
variables: {
id: user.id,
displayName: `${firstName} ${lastName}`.trim(),
metadata: {
firstName,
lastName,
},
},
});
toast.success('Updated successfully', { id: 'updateProfile' });
} catch (error) {
toast.error('Unable to update profile', { id: 'updateProfile' });
}
};
//...
};
```
Finally, since Hasura has an **allow nothing by default** policy, and we haven't
set any permissions yet, our GraphQL mutations would fail.
So, open the Hasura console from the **Data** tab of your project from [your Nhost dashboard](https://app.nhost.io/). Then, go to the **permissions** tab of the `users` table, type in `user` in the role
cell, and click the edit icon on the `select` operation:
![Hasura users permissions](/img/quickstarts/hasura-permissions-1.png)
To restrict the user to read his data only, specify a condition with the
user's ID and the `X-Hasura-User-ID` session variable, which is passed with each
requests.
![Hasura users permissions](/img/quickstarts/hasura-permissions-2.png)
Next, select the columns you'd like the users to have access to, and click
**Save Permissions**.
![Hasura users permissions](/img/quickstarts/hasura-permissions-3.png)
Repeat the same steps on the `update` operation for the `user` role to allow
users to update their `displayName` and `metadata` only.
Finally, to add caching, synchronizing, and updating server state in your Next.js app, let's refactor the user data fetching by using the Apollo client and our GraphQL API instead.
So, first add the following GraphQL query to retrieve the current user data from the `UserProvider.js` file:
```js title="UserProvider.js"
import { gql } from '@apollo/client';
const GET_USER_QUERY = gql`
query GetUser($id: uuid!) {
user(id: $id) {
id
email
displayName
metadata
avatarUrl
}
}
`;
export function UserProvider() {
//...
}
```
Then, replace the `useUserData` hook with the `useUserId` hook to retrieve the current user's ID only.
```js title="UserProvider.js"
import { useUserId } from '@nhost/nextjs';
export function UserProvider() {
const id = useUserId();
//...
}
```
Finally, we can run our GraphQL query using the `useQuery` hook and the current user's ID.
```jsx title="UserProvider.js"
// highlight-next-line
import { gql, useQuery } from '@apollo/client';
export function UserProvider({ children = null }) {
const id = useUserId();
// highlight-start
const { loading, error, data } = useQuery(GET_USER_QUERY, {
variables: { id },
});
const user = data?.user;
// highlight-end
// highlight-start
if (error) {
return <p>Something went wrong. Try to refresh the page.</p>;
}
if (loading) {
return null;
}
// highlight-end
return (
<UserContext.Provider value={{ user }}>{children}</UserContext.Provider>
);
}
```
You now have a fully functional Next.js application. Congratulations!
## Next Steps
- Did you enjoy Nhost? Give us a star ⭐ on [Github](https://github.com/nhost/nhost). Thank you!
- Check out our more in-depth [examples](https://github.com/nhost/nhost/tree/main/examples).
- Build your next app with [Nhost](https://app.nhost.io/)!

View File

@@ -0,0 +1,714 @@
---
title: 'Quickstart: React'
sidebar_position: 1
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Quickstart: React
## Introduction
This quickstart guide provides the steps you need to build a simple React app
powered by Nhost for the backend. It includes:
- Database: [PostgreSQL](https://www.postgresql.org/)
- Instant GraphQL API: [Hasura](https://hasura.io/)
- Authentication: [Hasura Auth](https://github.com/nhost/hasura-auth/)
- Storage: [Hasura Storage](https://hub.docker.com/r/nhost/hasura-storage)
By the end of this guide, you'll have a full-stack app that allows users to log
in to access a protected dashboard and update their profile information.
## Prerequisites
Before getting started, let's make sure that your development environment is
ready.
You'll need **Node.js** version 14 or later: [install it from here](https://nodejs.org/en/).
## Project setup
### Create a new Nhost app
First things first, we need to create a new Nhost project.
So, log in to your Nhost dashboard and click the **Create your first app**
button.
![nhost-first-app](/img/quickstarts/create-app-step-1.png)
Next, give your new Nhost app a name, select a geographic region for your Nhost
services and click **Create App**.
![nhost-first-app](/img/quickstarts/create-app-step-2.png)
After a few seconds, you should get a PostgreSQL database, a GraphQL API with
Hasura, file storage, and authentication set up.
:::info
You can also connect your Nhost app to a GitHub repository. When you do this, any updates you push to your code will automatically be deployed. [Learn more](https://docs.nhost.io/platform/github-integration).
:::
## Initialize the app
### Create a React app
The simplest way to create a new React application is by using the tool called
`create-react-app`, which bootstraps a React app for you without the hassle of
configuring everything yourself.
So, open your terminal, and run the following command:
```bash
npx create-react-app my-nhost-app --template nhost-quickstart
```
:::info
This command uses an [existing template](https://github.com/nhost/cra-template-nhost-quickstart), through the `--template` flag, which already contains the React components and pages we'll use for this guide.
:::
You can now `cd` into your project directory:
```bash
cd my-nhost-app
```
And run the development server with the following command:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm" default>
```bash
npm start
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn start
```
</TabItem>
</Tabs>
If everything is working fine, your React development server should be running
on port 3000. Open [http://localhost:3000](http://localhost:3000) from your
browser to check this out.
### Configure Nhost with React
To work with Nhost from within our React app, we'll use the
[React SDK](https://github.com/nhost/nhost/tree/main/packages/react) provided
by Nhost. It's a wrapper around the
[Nhost JavaScript SDK](https://github.com/nhost/nhost/tree/main/packages/nhost-js) which
gives us a way to interact with our Nhost backend using React hooks.
You can install the Nhost React SDK with:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm" default>
```bash
npm install @nhost/react graphql
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add @nhost/react graphql
```
</TabItem>
</Tabs>
Next, open your `App.js` file as we'll now configure Nhost inside our app.
The Nhost React SDK comes with a React provider named `NhostReactProvider` that
makes the authentication state and all the provided React hooks available in our
application.
Use the following code to instantiate a new Nhost client and link it to your
Nhost backend:
```jsx title="src/App.js"
import { NhostClient, NhostReactProvider } from '@nhost/react';
const nhost = new NhostClient({
backendUrl: process.env.REACT_APP_NHOST_BACKEND_URL || '',
});
function App() {
return (
<NhostReactProvider nhost={nhost}>
<BrowserRouter>{/* ... */}</BrowserRouter>
</NhostReactProvider>
);
}
export default App;
```
Finally, make sure to create an environment variable named
`REACT_APP_NHOST_BACKEND_URL` to store your Nhost backend URL:
```yaml title=".env.local"
REACT_APP_NHOST_BACKEND_URL=YOUR_NHOST_BACKEND_URL
```
You can find your Nhost backend URL for your project from [your dashboard](https://app.nhost.io) as shown below:
![Nhost Backend URL](/img/quickstarts/app-dashboard.png)
:::caution
Don't forget to restart your React server after saving your `.env.local`
file to load your new environment variable.
:::
## Build the app
### Add authentication
#### 1. Sign-up
The next step is to allow our users to authenticate into our application.
Let's start with implementing the sign-up process.
For that, we'll use the `useSignUpEmailPassword` hook provided by the Nhost
React SDK within our `SignUp` component.
So, open up the corresponding file from your project, and use the following
code:
```jsx title="src/components/SignUp.js"
import styles from '../styles/components/SignUp.module.css';
import { useState } from 'react';
import { useSignUpEmailPassword } from '@nhost/react';
import { Link, Navigate } from 'react-router-dom';
import Input from './Input';
import Spinner from './Spinner';
const SignUp = () => {
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const {
signUpEmailPassword,
isLoading,
isSuccess,
needsEmailVerification,
isError,
error,
} = useSignUpEmailPassword();
const handleOnSubmit = (e) => {
e.preventDefault();
signUpEmailPassword(email, password, {
displayName: `${firstName} ${lastName}`.trim(),
metadata: {
firstName,
lastName,
},
});
};
if (isSuccess) {
return <Navigate to="/" replace={true} />;
}
const disableForm = isLoading || needsEmailVerification;
return (
<div className={styles.container}>
<div className={styles.card}>
<div className={styles['logo-wrapper']}>
<img src={process.env.PUBLIC_URL + 'logo.svg'} alt="logo" />
</div>
{needsEmailVerification ? (
<p className={styles['verification-text']}>
Please check your mailbox and follow the verification link to verify
your email.
</p>
) : (
<form onSubmit={handleOnSubmit} className={styles.form}>
<div className={styles['input-group']}>
<Input
label="First name"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
disabled={disableForm}
required
/>
<Input
label="Last name"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
disabled={disableForm}
required
/>
</div>
<Input
type="email"
label="Email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={disableForm}
required
/>
<Input
type="password"
label="Create password"
value={password}
onChange={(e) => setPassword(e.target.value)}
disabled={disableForm}
required
/>
<button
type="submit"
disabled={disableForm}
className={styles.button}
>
{isLoading ? <Spinner size="sm" /> : 'Create account'}
</button>
{isError ? (
<p className={styles['error-text']}>{error?.message}</p>
) : null}
</form>
)}
</div>
<p className={styles.text}>
Already have an account?{' '}
<Link to="/sign-in" className={styles.link}>
Sign in
</Link>
</p>
</div>
);
};
export default SignUp;
```
By default, the user must verify his email address before fully signing up. You can change this setting from your Nhost dashboard.
#### 2. Sign-in
Now that new users can sign up for our application, let's see how to allow
existing users to sign in with email and password.
For that, we will use the Nhost hook named `useSignInEmailPassword` inside our
`SignIn` component the same way we did with our `SignUp` component. So, here's
what your component should look like after applying the changes for the sign-in
logic:
```jsx title="src/components/SignIn.js"
import styles from '../styles/components/SignIn.module.css';
import { useState } from 'react';
import { useSignInEmailPassword } from '@nhost/react';
import { Link, Navigate } from 'react-router-dom';
import Input from './Input';
import Spinner from './Spinner';
const SignIn = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const {
signInEmailPassword,
isLoading,
isSuccess,
needsEmailVerification,
isError,
error,
} = useSignInEmailPassword();
const handleOnSubmit = (e) => {
e.preventDefault();
signInEmailPassword(email, password);
};
if (isSuccess) {
return <Navigate to="/" replace={true} />;
}
const disableForm = isLoading || needsEmailVerification;
return (
<div className={styles.container}>
<div className={styles.card}>
<div className={styles['logo-wrapper']}>
<img src={process.env.PUBLIC_URL + 'logo.svg'} alt="logo" />
</div>
{needsEmailVerification ? (
<p className={styles['verification-text']}>
Please check your mailbox and follow the verification link to verify
your email.
</p>
) : (
<form onSubmit={handleOnSubmit} className={styles.form}>
<Input
type="email"
label="Email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={disableForm}
required
/>
<Input
type="password"
label="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
disabled={disableForm}
required
/>
<button
type="submit"
disabled={disableForm}
className={styles.button}
>
{isLoading ? <Spinner size="sm" /> : 'Sign in'}
</button>
{isError ? (
<p className={styles['error-text']}>{error?.message}</p>
) : null}
</form>
)}
</div>
<p className={styles.text}>
No account yet?{' '}
<Link to="/sign-up" className={styles.link}>
Sign up
</Link>
</p>
</div>
);
};
export default SignIn;
```
#### 3. Sign-out
Finally, to allow the users to sign out from the app, we can use the Nhost
`useSignOut` hook:
```jsx title="src/components/Layout.js"
import { useSignOut } from '@nhost/react';
const Layout = () => {
const { signOut } = useSignOut();
const menuItems = [
//..
{
label: 'Logout',
onClick: signOut,
icon: LogoutIcon,
},
];
//...
};
```
### Protect routes
Now that we have implemented authentication, we can easily decide who can access
certain parts of our application.
In our case, we'll only allow authenticated users to have access to the `/` and
`/profile` routes. All the other users should be redirected to the `/sign-in`
page if they try to access those routes.
To do so, we can create a wrapper component (`ProtectedRoute`) to check the authentication status of the current user using the Nhost SDK:
```jsx title="src/components/ProtectedRoute.js"
import styles from '../styles/components/ProtectedRoute.module.css';
import { useAuthenticationStatus } from '@nhost/react';
import { Navigate, useLocation } from 'react-router-dom';
import Spinner from './Spinner';
const ProtectedRoute = ({ children }) => {
const { isAuthenticated, isLoading } = useAuthenticationStatus();
const location = useLocation();
if (isLoading) {
return (
<div className={styles.container}>
<Spinner />
</div>
);
}
if (!isAuthenticated) {
return <Navigate to="/sign-in" state={{ from: location }} replace />;
}
return children;
};
export default ProtectedRoute;
```
Then, we can use a [layout route](https://reactrouter.com/docs/en/v6/getting-started/concepts#layout-routes) in our `App.js` file, to wrap the `ProtectedRoute` component around the routes we want to protect:
```jsx title="src/App.js"
import ProtectedRoute from './components/ProtectedRoute';
function App() {
return (
<NhostReactProvider nhost={nhost}>
<BrowserRouter>
<Routes>
<Route path="sign-up" element={<SignUp />} />
<Route path="sign-in" element={<SignIn />} />
<Route
path="/"
// highlight-start
element={
<ProtectedRoute>
<Layout />
</ProtectedRoute>
}
// highlight-end
>
<Route index element={<Dashboard />} />
<Route path="profile" element={<Profile />} />
</Route>
</Routes>
</BrowserRouter>
</NhostReactProvider>
);
}
```
### Retrieve user data
Finally, let's display the information of the authenticated user throughout his
dashboard to make the app more personalized.
Getting the current authenticated user data is quite easy. Indeed, we
can use the `useUserData` hook provided by Nhost to do it.
So, open the `components/Layout.js` file and use this hook like so:
```js
import { useUserData } from '@nhost/react';
const Layout = () => {
const user = useUserData();
//...
};
```
That's it! The JSX code for rendering the user data (email, display name, etc.)
is already included in your components as part of the template you've
bootstraped at the beginning of this guide.
### Update user data
Nhost provides a GraphQL API through Hasura so that we can query and mutate our
data instantly.
In this tutorial, we'll use the
[Apollo GraphQL client](https://www.apollographql.com/) for interacting with
this GraphQL API.
So, start by installing the following dependencies:
<Tabs groupId="package-manager">
<TabItem value="npm" label="npm" default>
```bash
npm install @nhost/react-apollo @apollo/client
```
</TabItem>
<TabItem value="yarn" label="Yarn">
```bash
yarn add @nhost/react-apollo @apollo/client
```
</TabItem>
</Tabs>
Then, add the `NhostApolloProvider` from `@nhost/react-apollo` into your
`App.js` file.
```jsx title="src/App.js"
import { NhostApolloProvider } from '@nhost/react-apollo';
function App() {
return (
<NhostReactProvider nhost={nhost}>
<NhostApolloProvider nhost={nhost}>{/* ... */}</NhostApolloProvider>
</NhostReactProvider>
);
}
```
From there, we can construct our GraphQL query and use the Apollo `useMutation`
hook to execute that query when the user submits the form from the profile page:
```js title="src/pages/Profile.js"
import { gql, useMutation } from '@apollo/client';
import { toast } from 'react-hot-toast';
const UPDATE_USER_MUTATION = gql`
mutation ($id: uuid!, $displayName: String!, $metadata: jsonb) {
updateUser(
pk_columns: { id: $id }
_set: { displayName: $displayName, metadata: $metadata }
) {
id
displayName
metadata
}
}
`;
const Profile = () => {
const [mutateUser, { loading: updatingProfile }] =
useMutation(UPDATE_USER_MUTATION);
const updateUserProfile = async (e) => {
e.preventDefault();
try {
await mutateUser({
variables: {
id: user.id,
displayName: `${firstName} ${lastName}`.trim(),
metadata: {
firstName,
lastName,
},
},
});
toast.success('Updated successfully', { id: 'updateProfile' });
} catch (error) {
toast.error('Unable to update profile', { id: 'updateProfile' });
}
};
//...
};
```
Finally, since Hasura has an **allow nothing by default** policy, and we haven't
set any permissions yet, our GraphQL mutations would fail.
So, open the Hasura console from the **Data** tab of your project from [your Nhost dashboard](https://app.nhost.io/). Then, go to the **permissions** tab of the `users` table, type in `user` in the role
cell, and click the edit icon on the `select` operation:
![Hasura users permissions](/img/quickstarts/hasura-permissions-1.png)
To restrict the user to read his own data only, specify a condition with the
user's ID and the `X-Hasura-User-ID` session variable, which is passed with each
requests.
![Hasura users permissions](/img/quickstarts/hasura-permissions-2.png)
Next, select the columns you'd like the users to have access to, and click
**Save Permissions**.
![Hasura users permissions](/img/quickstarts/hasura-permissions-3.png)
Repeat the same steps on the `update` operation for the `user` role to allow
users to update their `displayName` and `metadata` only.
Finally, to add caching, synchronizing, and updating server state in your React app, let's refactor the user data fetching using the Apollo client and our GraphQL API instead.
So, first add the following GraphQL query to retrieve the current user data from the `Layout` component:
```js title="src/components/Layout.js"
import { gql } from '@apollo/client';
const GET_USER_QUERY = gql`
query GetUser($id: uuid!) {
user(id: $id) {
id
email
displayName
metadata
avatarUrl
}
}
`;
const Layout = () => {
//...
};
```
Then, replace the `useUserData` hook with the `useUserId` hook to retrieve the current user's ID.
```js title="src/components/Layout.js"
import { useUserId } from '@nhost/react';
const Layout = () => {
const id = useUserId();
//...
};
```
Finally, we can run our GraphQL query using the `useQuery` hook and the current user's ID.
```jsx title="src/components/Layout.js"
// highlight-next-line
import { gql, useQuery } from '@apollo/client';
const Layout = () => {
const id = useUserId();
// highlight-start
const { loading, error, data } = useQuery(GET_USER_QUERY, {
variables: { id },
});
const user = data?.user;
// highlight-end
//...
return (
<div>
<header>{/* ... */}</header>
<main className={styles.main}>
<div className={styles['main-container']}>
{/* highlight-start */}
{error ? (
<p>Something went wrong. Try to refresh the page.</p>
) : !loading ? (
<Outlet context={{ user }} />
) : null}
{/* highlight-end */}
</div>
</main>
</div>
);
};
```
You now have a fully functional React application. Congratulations!
## Next Steps
- Did you enjoy Nhost? Give us a star ⭐ on [Github](https://github.com/nhost/nhost). Thank you!
- Check out our more in-depth [examples](https://github.com/nhost/nhost/tree/main/examples).
- Build your next app with [Nhost](https://app.nhost.io/)!

View File

@@ -0,0 +1,105 @@
---
title: 'Serverless Functions'
sidebar_position: 8
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
With Nhost, you can deploy Serverless Functions to execute custom code. Each serverless function is its HTTP endpoint.
Serverless functions can be used to handle [event triggers](/platform/database/event-triggers), form submission, integrations (e.g. Stripe, Slack, etc), and more.
---
## Creating a Serverless Function
Every `.js` (JavaScript) and `.ts` (TypeScript) file in the `functions/` folder of your Nhost app is its own serverless function.
<Tabs groupId="language">
<TabItem value="ts" label="TypeScript" default>
```ts title=functions/test.ts
import { Request, Response } from 'express'
export default (req: Request, res: Response) => {
res.status(200).send(`Hello ${req.query.name}!`)
}
```
:::info
You **MUST** install `express` locally in the base directory of your Nhost app.
```bash
npm install -d express @types/express
# or yarn
yarn add -d express @types/express
```
:::
</TabItem>
<TabItem value="js" label="JavaScript">
```js title=functions/test.js
export default (req, res) => {
res.status(200).send(`Hello ${req.query.name}!`)
}
```
:::info
You **MUST** install `express` locally in the base directory of your Nhost app.
```bash
npm install -d express
# or yarn
yarn add -d express
```
:::
</TabItem>
</Tabs>
## Deploying Serverless Functions
Serverless functions are automatically deployed using Nhost's [GitHub integration](/platform/github-integration).
You can prepend files and folders with an underscore (`_`) to prevent them from being treated as serverless functions and be turned into HTTP endpoints. This is useful if you have, for example, a utils file (`functions/_utils.js`) or a utils folder (`functions/_utils/[multiple-files].js`).
## Routing
HTTP endpoints are automatically generated based on the file structure inside `functions/`.
Here's an example of four serverless functions with their files and their HTTP endpoints:
| File | HTTP Endpoint |
| --------------------------- | ------------------------------------------------------------- |
| `functions/index.js` | `https://[app-subdomain].nhost.run/v1/functions/` |
| `functions/users/index.ts` | `https://[app-subdomain].nhost.run/v1/functions/users` |
| `functions/users/active.ts` | `https://[app-subdomain].nhost.run/v1/functions/users/active` |
| `functions/my-copmany.js` | `https://[app-subdomain].nhost.run/v1/functions/my-company` |
---
## Environment Variables
[Environment variables](/platform/environment-variables) are available inside your serverless functions. Both in production and when running Nhost locally using the [Nhost CLI](/platform/cli).
## Billing
Serverless functions are billed per GB-sec or GB-hour. 1 GB-hour is 3600 GB-seconds.
1 GB-sec is 1 function with 1 GB of RAM running for 1 second. If 1 function with 1 GB of RAM runs for 3600 seconds, that's the equivalent of 1 GB-hour.
All serverless functions in production are running with 128 MB of RAM.
## Node Version
All serverless functions in production are running Node.js version 14.x.
## Regions
Serverless Functions are always deployed to the same region as your app.

View File

@@ -1,4 +0,0 @@
{
"label": "Serverless Functions",
"position": 6
}

View File

@@ -1,62 +0,0 @@
---
title: 'Serverless Functions'
sidebar_position: 1
---
Nhost gives you the option to run serverless functions on the following runtimes:
- `Node.js 14` (Both JavaScript and Typescript)
---
## Creating functions
Every `.js` and `.ts` file in the `functions/` folder of your Nhost app will be exposed as an HTTP endpoint. You have to
```js
// In functions/hello/[name].js
export default (req, res) => {
res.status(200).send(`Hello ${req.query.name}!`);
};
```
Or, if you prefer TypeScript:
```ts
// In functions/hello/[name].ts
import { Request, Response } from 'express';
export default (req: Request, res: Response) => {
res.status(200).send(`Hello ${req.query.name}!`);
};
```
---
## Routing
HTTP endpoints are automatically generated based on the file structure under `functions/`.
As such, given this file structure:
```text
functions/index.js
functions/users/index.ts
functions/active.ts
functions/my-company.js
```
The following endpoints will be available:
- https://yourappid.nhost.run/v1/functions/ from `functions/index.js`.
- https://yourappid.nhost.run/v1/functions/users from `functions/users/index.ts`.
- https://yourappid.nhost.run/v1/functions/users/active from `functions/users/active.ts`.
- https://yourappid.nhost.run/v1/functions/my-company from `functions/my-company.js`.
If you've used Netlify or Vercel, this routing logic will be familiar to you.
---
## Infrastructure
Serverless Functions are deployed to AWS Lambda in the same region as your app.

View File

@@ -1,5 +1,6 @@
---
title: 'Storage'
sidebar_position: 7
---
Nhost stores and serves files of any type in your backend.

View File

@@ -1,4 +0,0 @@
{
"label": "Storage",
"position": 5
}

View File

@@ -1,5 +0,0 @@
{
"label": "CLI",
"position": 4,
"link": { "type": "generated-index", "slug": "/reference/cli" }
}

View File

@@ -0,0 +1,16 @@
---
title: 'down'
sidebar_position: 3
---
Delete all containers created by `nhost up`
```bash
nhost down
```
To delete all containers **and the local database**, append `--data` to the command.
```bash
nhost down --data
```

View File

@@ -0,0 +1,22 @@
---
title: 'Global Flags'
sidebar_position: 9
---
### `--debug`, `-d`
Turn on debug output.
```bash
nhost up --debug
nhost init -d
```
### `--log-file`, `-f`
Save output to a given file.
```bash
nhost up -d --log-file some-file.txt
nhost logs -f some-file.txt
```

View File

@@ -0,0 +1,6 @@
---
title: 'CLI'
sidebar_position: 1
---
This section is a reference for the commands available in the [Nhost CLI](/platform/cli).

View File

@@ -0,0 +1,18 @@
---
title: 'init'
sidebar_position: 1
---
Intialize a local Nhost app in the current working directory.
```
nhost init
```
If you already have a Nhost app in Nhost Cloud you can use that app as a starting point by appending `--remote` to the command.
This will pull the database migrations and Hasura metadata from the Nhost Cloud app locally for you to use as a starting point.
```
nhost init --remote
```

View File

@@ -0,0 +1,10 @@
---
title: 'link'
sidebar_position: 4
---
Link the local Nhost app in your working directory to an app in Nhost Cloud.
```bash
nhost link
```

View File

@@ -0,0 +1,10 @@
---
title: 'list'
sidebar_position: 7
---
List all your Nhost apps in Nhost Cloud.
```bash
nhost list
```

View File

@@ -0,0 +1,10 @@
---
title: 'login'
sidebar_position: 5
---
Authenticate the CLI with your Nhost user.
```bash
nhost login
```

View File

@@ -0,0 +1,10 @@
---
title: 'logout'
sidebar_position: 6
---
Remove authentication for the CLI.
```bash
nhost logout
```

View File

@@ -0,0 +1,10 @@
---
title: 'logs'
sidebar_position: 9
---
Output logs of any service container
```bash
nhost logs
```

View File

@@ -1,97 +0,0 @@
---
title: 'Nhost CLI'
---
Run `nhost help` in your terminal to get a detailed listing of all available commands.
---
## `nhost`
Run the Nhost development environment. If the current directory has not been initialized as an Nhost app, `nhost` will run you through the initialization.
```bash
nhost
```
### Frontend templates
The `nhost` command will offer you the option of cloning frontend templates for framework of your choice (Nuxt, Next.js, React).
The frontend template will be cloned in the `web/` directory of your app root. It will have the Nhost SDK preinstalled and configured.
---
## `nhost dev`
Launch the development environment for your app.
```bash
nhost dev
```
To trace all output and debug issues, run `nhost dev --debug`.
```bash
nhost dev --debug
```
---
## `nhost init`
Intialize a blank local app in current working directory:
```bash
nhost init
```
Or clone an existing app from [nhost.io](https://nhost.io):
```bash
nhost init --remote
```
---
## `nhost link`
Link the local Nhost app in your working directory to [nhost.io](https://nhost.io).
```bash
nhost link
```
---
## `nhost logs`
Check real-time logs of any service container
You can run this command in parallel, while your local environment is already running. Use `-f` to save output to a file.
```bash
nhost logs
```
---
## Global flags
Turn on debug output.
#### `--debug`, `-d`
```bash
nhost dev --debug
nhost init -d
```
#### `--log-file`, `-f`
Save output to a given file.
```bash
nhost dev -d --log-file some-file.txt
nhost logs -f some-file.txt
```

View File

@@ -0,0 +1,14 @@
---
title: 'up'
sidebar_position: 2
---
Launch the development environment for your app. Once the environment is up, the command will:
- Apply database migrations.
- Apply the Hasura metadata.
- Apply seed data.
```bash
nhost up
```

View File

@@ -0,0 +1,10 @@
---
title: 'upgrade'
sidebar_position: 8
---
Upgrade the CLI to the latest version.
```bash
nhost upgrade
```

View File

@@ -0,0 +1,3 @@
{
"label": "Auth"
}

View File

@@ -0,0 +1,33 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: signUp()
sidebar_label: signUp()
slug: /reference/javascript/auth/sign-up
description: Use `nhost.auth.signUp` to sign up a user using email and password. If you want to sign up a user using passwordless email (Magic Link), SMS, or an OAuth provider, use the `signIn` function instead.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L93
---
# `signUp()`
Use `nhost.auth.signUp` to sign up a user using email and password. If you want to sign up a user using passwordless email (Magic Link), SMS, or an OAuth provider, use the `signIn` function instead.
```ts
nhost.auth.signUp({
email: 'joe@example.com',
password: 'secret-password'
})
```
## Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`SignUpEmailPasswordParams`](/reference/docgen/javascript/auth/types/sign-up-email-password-params)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------ | :-------------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">params.</span>password</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">params.</span>email</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">params.</span>options</span> | `SignUpOptions` | | |
---

View File

@@ -0,0 +1,60 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: signIn()
sidebar_label: signIn()
slug: /reference/javascript/auth/sign-in
description: Use `nhost.auth.signIn` to sign in a user using email and password, passwordless (email or sms) or an external provider. `signIn` can be used to sign in a user in various ways depending on the parameters.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L156
---
# `signIn()`
Use `nhost.auth.signIn` to sign in a user using email and password, passwordless (email or sms) or an external provider. `signIn` can be used to sign in a user in various ways depending on the parameters.
```ts
nhost.auth.signIn({
email: 'joe@example.com',
password: 'secret-password'
})
```
## Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`SignInParams`](/reference/docgen/javascript/auth/types/sign-in-params)
---
## Examples
### Sign in a user using email and password
```ts
nhost.auth.signIn({
email: 'joe@example.com',
password: 'secret-password'
})
```
### Sign in a user using an OAuth provider (e.g: Google or Facebook)
```ts
nhost.auth.signIn({ provider: 'google' })
```
### Sign in a user using passwordless email (Magic Link)
```ts
nhost.auth.signIn({ email: 'joe@example.com' })
```
### Sign in a user using passwordless SMS
```ts
// [step 1/2] Passwordless sign in using SMS
nhost.auth.signIn({ phoneNumber: '001122334455' })
// [step 2/2] Finish passwordless sign in using SMS (OTP)
nhost.auth.signIn({ phoneNumber: '001122334455', otp: '123456' })
```

View File

@@ -0,0 +1,38 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: signOut()
sidebar_label: signOut()
slug: /reference/javascript/auth/sign-out
description: Use `nhost.auth.signOut` to sign out the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L338
---
# `signOut()`
Use `nhost.auth.signOut` to sign out the user.
```ts
nhost.auth.signOut()
```
## Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">optional</span> `{ all: boolean }`
---
## Examples
### Sign out the user from current device
```ts
nhost.auth.signOut()
```
### Sign out the user from all decvices
```ts
nhost.auth.signOut({ all: true })
```

View File

@@ -0,0 +1,29 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: resetPassword()
sidebar_label: resetPassword()
slug: /reference/javascript/auth/reset-password
description: Use `nhost.auth.resetPassword` to reset the password for a user. This will send a reset-password link in an email to the user. When the user clicks the reset-password link the user is automatically signed-in. Once signed-in, the user can change their password using `nhost.auth.changePassword()`.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L365
---
# `resetPassword()`
Use `nhost.auth.resetPassword` to reset the password for a user. This will send a reset-password link in an email to the user. When the user clicks the reset-password link the user is automatically signed-in. Once signed-in, the user can change their password using `nhost.auth.changePassword()`.
```ts
nhost.auth.resetPassword({ email: 'joe@example.com' })
```
## Parameters
---
**<span className="parameter-name">\_\_namedParameters</span>** <span className="optional-status">required</span> [`ResetPasswordParams`](/reference/docgen/javascript/auth/types/reset-password-params)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------------------ | :--------------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>email</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>options</span> | `RedirectOption` | | |
---

View File

@@ -0,0 +1,28 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: changePassword()
sidebar_label: changePassword()
slug: /reference/javascript/auth/change-password
description: Use `nhost.auth.changePassword` to change the password for the user. The old password is not needed.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L390
---
# `changePassword()`
Use `nhost.auth.changePassword` to change the password for the user. The old password is not needed.
```ts
nhost.auth.changePassword({ newPassword: 'new-secret-password' })
```
## Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`ChangePasswordParams`](/reference/docgen/javascript/auth/types/change-password-params)
| Property | Type | Required | Notes |
| :--------------------------------------------------------------------------------------------- | :------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">params.</span>newPassword</span> | `string` | ✔️ | |
---

View File

@@ -0,0 +1,29 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: sendVerificationEmail()
sidebar_label: sendVerificationEmail()
slug: /reference/javascript/auth/send-verification-email
description: Use `nhost.auth.sendVerificationEmail` to send a verification email to the specified email. The email contains a verification-email link. When the user clicks the verification-email link their email is verified.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L415
---
# `sendVerificationEmail()`
Use `nhost.auth.sendVerificationEmail` to send a verification email to the specified email. The email contains a verification-email link. When the user clicks the verification-email link their email is verified.
```ts
nhost.auth.sendVerificationEmail({ email: 'joe@example.com' })
```
## Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`SendVerificationEmailParams`](/reference/docgen/javascript/auth/types/send-verification-email-params)
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------- | :--------------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">params.</span>email</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">params.</span>options</span> | `RedirectOption` | | |
---

View File

@@ -0,0 +1,29 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: changeEmail()
sidebar_label: changeEmail()
slug: /reference/javascript/auth/change-email
description: Use `nhost.auth.changeEmail` to change a user's email. This will send a confirm-email-change link in an email to the new email. Once the user clicks on the confirm-email-change link the email will be change to the new email.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L442
---
# `changeEmail()`
Use `nhost.auth.changeEmail` to change a user's email. This will send a confirm-email-change link in an email to the new email. Once the user clicks on the confirm-email-change link the email will be change to the new email.
```ts
nhost.auth.changeEmail({ newEmail: 'doe@example.com' })
```
## Parameters
---
**<span className="parameter-name">\_\_namedParameters</span>** <span className="optional-status">required</span> [`ChangeEmailParams`](/reference/docgen/javascript/auth/types/change-email-params)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------------------- | :--------------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>newEmail</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>options</span> | `RedirectOption` | | |
---

View File

@@ -0,0 +1,36 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: deanonymize()
sidebar_label: deanonymize()
slug: /reference/javascript/auth/deanonymize
description: Use `nhost.auth.deanonymize` to deanonymize a user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L467
---
# `deanonymize()`
Use `nhost.auth.deanonymize` to deanonymize a user.
```ts
nhost.auth.deanonymize({
signInMethod: 'email-password',
email: 'joe@example.com'
})
```
## Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`DeanonymizeParams`](/reference/docgen/javascript/auth/types/deanonymize-params)
| Property | Type | Required | Notes |
| :---------------------------------------------------------------------------------------------- | :------------------------------------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">params.</span>email</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">params.</span>signInMethod</span> | `"email-password"` \| `"passwordless"` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">params.</span>allowedRoles</span> | `Array<string>` | | |
| <span className="parameter-name"><span className="light-grey">params.</span>defaultRole</span> | `string` | | |
| <span className="parameter-name"><span className="light-grey">params.</span>connection</span> | `"email"` \| `"sms"` | | |
| <span className="parameter-name"><span className="light-grey">params.</span>password</span> | `string` | | |
---

View File

@@ -0,0 +1,26 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: onTokenChanged()
sidebar_label: onTokenChanged()
slug: /reference/javascript/auth/on-token-changed
description: Use `nhost.auth.onTokenChanged` to add a custom function that runs every time the access or refresh token is changed.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L501
---
# `onTokenChanged()`
Use `nhost.auth.onTokenChanged` to add a custom function that runs every time the access or refresh token is changed.
```ts
nhost.auth.onTokenChanged(() =>
console.log('The access and refresh token has changed')
)
```
## Parameters
---
**<span className="parameter-name">fn</span>** <span className="optional-status">required</span> [`OnTokenChangedFunction`](/reference/docgen/javascript/auth/types/on-token-changed-function)
---

View File

@@ -0,0 +1,28 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: onAuthStateChanged()
sidebar_label: onAuthStateChanged()
slug: /reference/javascript/auth/on-auth-state-changed
description: Use `nhost.auth.onAuthStateChanged` to add a custom function that runs every time the authentication status of the user changes. E.g. add a custom function that runs every time the authentication status changes from signed-in to signed-out.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L536
---
# `onAuthStateChanged()`
Use `nhost.auth.onAuthStateChanged` to add a custom function that runs every time the authentication status of the user changes. E.g. add a custom function that runs every time the authentication status changes from signed-in to signed-out.
```ts
nhost.auth.onAuthStateChanged((event, session) => {
console.log(
`The auth state has changed. State is now ${event} with session: ${session}`
)
})
```
## Parameters
---
**<span className="parameter-name">fn</span>** <span className="optional-status">required</span> [`AuthChangedFunction`](/reference/docgen/javascript/auth/types/auth-changed-function)
---

View File

@@ -0,0 +1,20 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: isAuthenticated()
sidebar_label: isAuthenticated()
slug: /reference/javascript/auth/is-authenticated
description: Use `nhost.auth.isAuthenticated` to check if the user is authenticated or not.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L578
---
# `isAuthenticated()`
Use `nhost.auth.isAuthenticated` to check if the user is authenticated or not.
```ts
const isAuthenticated = nhost.auth.isAuthenticated()
if (isAuthenticated) {
console.log('User is authenticated')
}
```

View File

@@ -0,0 +1,20 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: isAuthenticatedAsync()
sidebar_label: isAuthenticatedAsync()
slug: /reference/javascript/auth/is-authenticated-async
description: Use `nhost.auth.isAuthenticatedAsync` to wait (await) for any internal authentication network requests to finish and then return the authentication status.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L596
---
# `isAuthenticatedAsync()`
Use `nhost.auth.isAuthenticatedAsync` to wait (await) for any internal authentication network requests to finish and then return the authentication status.
```ts
const isAuthenticated = await nhost.auth.isAuthenticatedAsync()
if (isAuthenticated) {
console.log('User is authenticated')
}
```

View File

@@ -0,0 +1,24 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getAuthenticationStatus()
sidebar_label: getAuthenticationStatus()
slug: /reference/javascript/auth/get-authentication-status
description: Use `nhost.auth.getAuthenticationStatus` to get the authentication status of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L621
---
# `getAuthenticationStatus()`
Use `nhost.auth.getAuthenticationStatus` to get the authentication status of the user.
```ts
const { isAuthenticated, isLoading } = nhost.auth.getAuthenticationStatus()
if (isLoading) {
console.log('Loading...')
}
if (isAuthenticated) {
console.log('User is authenticated')
}
```

View File

@@ -0,0 +1,15 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getJWTToken()
sidebar_label: getJWTToken()
slug: /reference/javascript/auth/get-jwt-token
sidebar_class_name: deprecated
description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L635
---
# `getJWTToken()`
:::caution Deprecated
Use `nhost.auth.getAccessToken()` instead.
:::

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getAccessToken()
sidebar_label: getAccessToken()
slug: /reference/javascript/auth/get-access-token
description: Use `nhost.auth.getAccessToken` to get the access token of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L649
---
# `getAccessToken()`
Use `nhost.auth.getAccessToken` to get the access token of the user.
```ts
const accessToken = nhost.auth.getAccessToken()
```

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getDecodedAccessToken()
sidebar_label: getDecodedAccessToken()
slug: /reference/javascript/auth/get-decoded-access-token
description: Use `nhost.auth.getDecodedAccessToken` to get the decoded access token of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L663
---
# `getDecodedAccessToken()`
Use `nhost.auth.getDecodedAccessToken` to get the decoded access token of the user.
```ts
const decodedAccessToken = nhost.auth.getDecodedAccessToken()
```

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getHasuraClaims()
sidebar_label: getHasuraClaims()
slug: /reference/javascript/auth/get-hasura-claims
description: Use `nhost.auth.getHasuraClaims` to get the Hasura claims of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L679
---
# `getHasuraClaims()`
Use `nhost.auth.getHasuraClaims` to get the Hasura claims of the user.
```ts
const hasuraClaims = nhost.auth.getHasuraClaims()
```

View File

@@ -0,0 +1,27 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getHasuraClaim()
sidebar_label: getHasuraClaim()
slug: /reference/javascript/auth/get-hasura-claim
description: Use `nhost.auth.getHasuraClaim` to get the value of a specific Hasura claim of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L696
---
# `getHasuraClaim()`
Use `nhost.auth.getHasuraClaim` to get the value of a specific Hasura claim of the user.
```ts
// if `x-hasura-company-id` exists as a custom claim
const companyId = nhost.auth.getHsauraClaim('company-id')
```
## Parameters
---
**<span className="parameter-name">name</span>** <span className="optional-status">required</span> `string`
Name of the variable. You don't have to specify `x-hasura-`.
---

View File

@@ -0,0 +1,28 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: refreshSession()
sidebar_label: refreshSession()
slug: /reference/javascript/auth/refresh-session
description: Use `nhost.auth.refreshSession` to refresh the session with either the current internal refresh token or an external refresh token.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L719
---
# `refreshSession()`
Use `nhost.auth.refreshSession` to refresh the session with either the current internal refresh token or an external refresh token.
```ts
// Refresh the session with the the current internal refresh token.
nhost.auth.refreshToken()
// Refresh the session with an external refresh token.
nhost.auth.refreshToken(refreshToken)
```
## Parameters
---
**<span className="parameter-name">refreshToken</span>** <span className="optional-status">optional</span> `string`
---

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getSession()
sidebar_label: getSession()
slug: /reference/javascript/auth/get-session
description: Use `nhost.auth.getSession()` to get the session of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L763
---
# `getSession()`
Use `nhost.auth.getSession()` to get the session of the user.
```ts
const session = nhost.auth.getSession()
```

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: getUser()
sidebar_label: getUser()
slug: /reference/javascript/auth/get-user
description: Use `nhost.auth.getUser()` to get the signed-in user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L778
---
# `getUser()`
Use `nhost.auth.getUser()` to get the signed-in user.
```ts
const user = nhsot.auth.getUser()
```

View File

@@ -0,0 +1,31 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: HasuraAuthClient
sidebar_label: Auth
description: No description provided.
slug: /reference/javascript/auth
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L51
---
# `HasuraAuthClient`
## Parameters
---
**<span className="parameter-name">\_\_namedParameters</span>** <span className="optional-status">required</span> [`NhostAuthConstructorParams`](/reference/docgen/javascript/auth/types/nhost-auth-constructor-params)
| Property | Type | Required | Notes |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------ | :------: | :---------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>url</span> | `string` | ✔️ | |
| <span className="parameter-name deprecated"><span className="light-grey">\_\_namedParameters.</span>autoLogin</span> <span className="deprecation-sign" title="@alias autoSignIn - use autoSignIn instead">⚠️</span> | `boolean` | | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>start</span> | `boolean` | | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name deprecated"><span className="light-grey">\_\_namedParameters.</span>clientStorageSetter</span> <span className="deprecation-sign" title="Use clientStorage / clientStorageType instead">⚠️</span> | [`StorageSetter`](/reference/docgen/javascript/auth/types/storage-setter) | | Define a way to set information about the refresh token and its exipration date. |
| <span className="parameter-name deprecated"><span className="light-grey">\_\_namedParameters.</span>clientStorageGetter</span> <span className="deprecation-sign" title="Use clientStorage / clientStorageType instead">⚠️</span> | [`StorageGetter`](/reference/docgen/javascript/auth/types/storage-getter) | | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
---

Some files were not shown because too many files have changed in this diff Show More