Compare commits

...

53 Commits

Author SHA1 Message Date
Pilou
57726864fd Merge pull request #1144 from nhost/ci/fix-dashboard-version
ci: fix version
2022-11-18 16:19:07 +01:00
Pierre-Louis Mercereau
9d2fdbadc8 ci: remove env cmd 2022-11-18 15:35:13 +01:00
Pierre-Louis Mercereau
6bd874b485 ci: correct env 2022-11-18 15:19:07 +01:00
Pierre-Louis Mercereau
4b36670897 ci: config turborepo 2022-11-18 15:10:50 +01:00
Pierre-Louis Mercereau
947696efc6 ci: fix version 2022-11-18 14:52:01 +01:00
Pilou
a3168a1dae Merge pull request #1143 from nhost/ci/turbo-cache
ci: fix typo
2022-11-18 14:48:52 +01:00
Pierre-Louis Mercereau
29efea2ad8 ci: fix typo 2022-11-18 14:44:05 +01:00
Pilou
390688feb1 Merge pull request #1142 from nhost/ci/turbo-cache
ci: use turborepo cache when building images
2022-11-18 13:48:29 +01:00
Pierre-Louis Mercereau
20e19ec7db ci: use turborepo cache when building images 2022-11-18 13:27:59 +01:00
Szilárd Dóró
b0c58ff351 Merge pull request #1141 from nhost/changeset-release/main
chore: update versions
2022-11-18 12:18:40 +01:00
github-actions[bot]
7b7cc74948 chore: update versions 2022-11-18 11:17:45 +00:00
Szilárd Dóró
1f501c829c Merge pull request #1123 from nhost/dashboard-docker
Dashboard Docker
2022-11-18 12:15:05 +01:00
Szilárd Dóró
8f9993d8ed chore(dashboard): bump graphiql, fix React warning 2022-11-18 10:31:27 +01:00
Pilou
f53b1f5c13 Merge pull request #1140 from nhost/chore/no-gyp
chore: get rid of node-gyp and its bin dependencies
2022-11-18 10:10:16 +01:00
Pierre-Louis Mercereau
1b8dcf237a chore: get rid of node-gyp and its bin dependencies 2022-11-18 10:07:22 +01:00
Szilárd Dóró
fc559d9e29 chore(changesets): fix review comments 2022-11-18 09:16:24 +01:00
Szilárd Dóró
fe61dbb6dc fix(changesets): push Docker image 2022-11-18 09:06:01 +01:00
Pilou
8f90569230 Merge pull request #1135 from nhost/docs/inline-webauthn
docs: inline webauthn examples
2022-11-17 21:33:05 +01:00
Szilárd Dóró
5a11ace8f0 chore(changesets): incorporate publishing in changesets 2022-11-17 15:49:58 +01:00
Szilárd Dóró
c569c5f60c fix(dashboard): don't block render because of health check 2022-11-17 15:18:44 +01:00
Johan Eliasson
fbcef432a3 Merge pull request #1134 from nhost/elitan-patch-3
Update storage.mdx
2022-11-17 14:57:30 +01:00
Szilárd Dóró
44ae629f86 fix(publish): correct workflow 2022-11-17 13:14:58 +01:00
Szilárd Dóró
e030856660 fix(changesets): remove publish step 2022-11-17 10:47:23 +01:00
Szilárd Dóró
db118f9769 chore(actions): extract publish to a separate workflow 2022-11-17 10:35:29 +01:00
Szilárd Dóró
8a48a897a7 feat(changesets): add Docker publish step 2022-11-17 09:41:13 +01:00
Szilárd Dóró
dce91ec7d8 fix(dashboard): correct client for local development 2022-11-17 09:31:47 +01:00
Pierre-Louis Mercereau
0a3383d6c5 chore: typo 2022-11-17 08:14:22 +01:00
Pierre-Louis Mercereau
97b5310c5d docs: inline webauthn examples 2022-11-17 08:10:48 +01:00
Johan Eliasson
5c8c79444a Update storage.mdx 2022-11-16 23:35:08 +01:00
Johan Eliasson
eb3041341d Merge pull request #1115 from nhost/docs-updates-8yg9hjasd
Docs updates
2022-11-16 23:29:16 +01:00
Szilárd Dóró
f57f237e37 chore(dashboard): create changelog 2022-11-16 16:44:54 +01:00
Szilárd Dóró
b1e90e6e2b Merge branch 'main' into dashboard-docker 2022-11-16 16:21:20 +01:00
Szilárd Dóró
1c947b2995 chore(dashboard): add missing env vars to Dockerfile 2022-11-16 12:42:36 +01:00
Johan Eliasson
d00f6ed84e Update docs/docs/platform/multiple-environments.mdx
Co-authored-by: Szilárd Dóró <doroszilard@icloud.com>
2022-11-16 12:22:34 +01:00
Johan Eliasson
4c88846d72 Update docs/docs/reference/cli/init.mdx
Co-authored-by: Pilou <24897252+plmercereau@users.noreply.github.com>
2022-11-16 12:21:21 +01:00
Johan Eliasson
97dc689d79 redirect update 2022-11-16 08:32:01 +01:00
Johan Eliasson
311417d679 typo 2022-11-16 08:27:07 +01:00
Johan Eliasson
ce0e1ee7ae redirect update 2022-11-16 08:24:04 +01:00
Johan Eliasson
1cc6841107 redirect update 2022-11-16 08:19:49 +01:00
Johan Eliasson
4b7fff0440 redirect update 2022-11-16 08:16:43 +01:00
Johan Eliasson
47fc7ffc0e testing redirects 2022-11-16 08:05:26 +01:00
Szilárd Dóró
7c5d0d0ec6 fix(dashboard): copy public folder 2022-11-15 18:02:59 +01:00
Szilárd Dóró
4d9c48f524 chore(dashboard): move Dockerfile, update commands 2022-11-15 15:17:19 +01:00
Szilárd Dóró
842e9892c0 chore(dashboard): update Dockerfile 2022-11-15 12:05:18 +01:00
Johan Eliasson
37fee16552 Merge branch 'main' into docs-updates-8yg9hjasd 2022-11-15 10:58:20 +01:00
Johan Eliasson
d056fb4dbd Merge branch 'main' into docs-updates-8yg9hjasd 2022-11-14 11:25:36 +01:00
Johan Eliasson
ed6d9e8a85 Dashboard Docker 2022-11-14 11:11:46 +01:00
Johan Eliasson
7840201e91 cli ref updates 2022-11-14 10:21:40 +01:00
Johan Eliasson
af8891686b updates 2022-11-14 10:11:46 +01:00
Johan Eliasson
13efafb000 multiple environments first draft 2022-11-12 10:01:46 +01:00
Johan Eliasson
719a3ddcf9 crazy update 2022-11-11 22:38:22 +01:00
Johan Eliasson
d11980f078 update 2022-11-11 11:16:26 +01:00
Johan Eliasson
bfbe8733f6 updates 2022-11-11 10:01:02 +01:00
142 changed files with 931 additions and 936 deletions

9
.dockerignore Normal file
View File

@@ -0,0 +1,9 @@
**/node_modules
**/npm-debug.log
**/out
**/dist
**/umd
**/.turbo
**/.nhost
**/coverage
**/.next

View File

@@ -5,24 +5,26 @@ on:
branches: [main]
paths-ignore:
- 'docs/**'
- 'dashboard/**'
- 'examples/**'
- 'assets/**'
- '**.md'
- '!.changeset/**'
- 'LICENSE'
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: nhost
jobs:
version:
runs-on: ubuntu-latest
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
dashboardVersion: ${{ steps.dashboard.outputs.dashboardVersion }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# * Install Node and dependencies
- name: Install Node and dependencies
uses: ./.github/actions/install-dependencies
- name: Create PR or Publish release
@@ -36,3 +38,55 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Tag Dashboard
id: dashboard
if: steps.changesets.outputs.hasChangesets == 'false'
run: |
package="@nhost/dashboard"
version=$(jq -r .version dashboard/package.json)
tag="$package@$version"
git tag $tag 2>/dev/null && (git push origin --tags ; echo "dashboardVersion=$version" >> $GITHUB_OUTPUT) || true
publish:
runs-on: ubuntu-latest
needs: version
if: needs.version.outputs.dashboardVersion != ''
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
nhost/dashboard
tags: |
type=raw,value=latest,enable=true
type=semver,pattern={{version}},value=v${{ needs.version.outputs.dashboardVersion }}
type=semver,pattern={{major}}.{{minor}},value=v${{ needs.version.outputs.dashboardVersion }}
type=semver,pattern={{major}},value=v${{ needs.version.outputs.dashboardVersion }}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push to Docker Hub
uses: docker/build-push-action@v3
timeout-minutes: 60
with:
context: .
file: ./dashboard/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
TURBO_TOKEN=${{ env.TURBO_TOKEN }}
TURBO_TEAM=${{ env.TURBO_TEAM }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true

View File

@@ -4,11 +4,13 @@ on:
push:
branches: [main]
paths:
- 'packages/**'
- 'dashboard/**'
pull_request:
branches: [main]
types: [opened, synchronize]
paths:
- 'packages/**'
- 'dashboard/**'
env:

7
dashboard/CHANGELOG.md Normal file
View File

@@ -0,0 +1,7 @@
# @nhost/dashboard
## 0.2.0
### Minor Changes
- db118f97: feat(dashboard): generate Docker image

50
dashboard/Dockerfile Normal file
View File

@@ -0,0 +1,50 @@
FROM node:16-alpine AS pruner
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope="@nhost/dashboard" --docker
FROM node:16-alpine AS builder
ARG TURBO_TOKEN
ARG TURBO_TEAM
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_PUBLIC_NHOST_PLATFORM false
ENV NEXT_PUBLIC_NHOST_MIGRATIONS_URL http://localhost:9693
ENV NEXT_PUBLIC_NHOST_HASURA_URL http://localhost:9695
ENV NEXT_PUBLIC_ENV dev
RUN yarn global add pnpm
COPY .gitignore .gitignore
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-*.yaml .
RUN pnpm install --frozen-lockfile
COPY --from=pruner /app/out/full/ .
COPY turbo.json turbo.json
COPY config/ config/
RUN pnpm build:dashboard
FROM node:16-alpine AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=builder /app/dashboard/next.config.js .
COPY --from=builder /app/dashboard/package.json .
COPY --from=builder /app/dashboard/public ./dashboard/public
COPY --from=builder --chown=nextjs:nodejs /app/dashboard/.next/standalone/app ./
COPY --from=builder --chown=nextjs:nodejs /app/dashboard/.next/static ./dashboard/.next/static
CMD node dashboard/server.js

View File

@@ -49,8 +49,8 @@ NEXT_PUBLIC_NHOST_MIGRATIONS_URL=http://localhost:9693
| `NEXT_PUBLIC_NHOST_PLATFORM` | This should be set to `false` to connect the Nhost Dashboard to a locally running Nhost backend. |
| `NEXT_PUBLIC_NHOST_MIGRATIONS_URL` | URL of Hasura's migrations endpoint. Used only if local development is enabled. |
| `NEXT_PUBLIC_NHOST_HASURA_URL` | URL of the Hasura Console. Used only when `NEXT_PUBLIC_ENV` is `dev`. |
| `NEXT_PUBLIC_NHOST_BACKEND_URL` | URL of the local backend. This is `http://localhost:1337` by default. |
| `NEXT_PUBLIC_ENV` | `dev`, `staging` or `prod`. Should be set to `dev` in most cases. |
| `NEXT_PUBLIC_NHOST_BACKEND_URL` | Backend URL. Not necessary for local development. |
| `NEXT_PUBLIC_STRIPE_PK` | Stripe public key. Not necessary for local development. |
| `NEXT_PUBLIC_GITHUB_APP_INSTALL_URL` | URL of the GitHub application. Not necessary for local development. |
| `NEXT_PUBLIC_ANALYTICS_WRITE_KEY` | Analytics key. Not necessary for local development. |

View File

@@ -1,3 +1,4 @@
const path = require('path');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
@@ -5,6 +6,10 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
module.exports = withBundleAnalyzer({
reactStrictMode: true,
swcMinify: false,
output: 'standalone',
experimental: {
outputFileTracingRoot: path.join(__dirname, '../../'),
},
eslint: {
dirs: ['src'],
},

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
@@ -25,7 +25,7 @@
"@emotion/styled": "^11.10.5",
"@fontsource/inter": "^4.5.14",
"@fontsource/roboto-mono": "^4.5.8",
"@graphiql/react": "^0.13.2",
"@graphiql/react": "^0.14.0",
"@graphiql/toolkit": "^0.8.0",
"@headlessui/react": "^1.6.5",
"@heroicons/react": "^1.0.6",
@@ -51,7 +51,7 @@
"cross-fetch": "^3.1.5",
"date-fns": "^2.29.3",
"generate-password": "^1.7.0",
"graphiql": "^2.0.8",
"graphiql": "^2.1.0",
"graphql": "^16.6.0",
"graphql-request": "^4.3.0",
"graphql-tag": "^2.12.6",
@@ -73,6 +73,7 @@
"react-merge-refs": "^1.1.0",
"react-syntax-highlighter": "^15.4.5",
"react-table": "^7.8.0",
"sharp": "^0.31.2",
"slugify": "^1.6.5",
"smartlook-client": "^6.0.0",
"stripe": "^10.17.0",

View File

@@ -65,7 +65,7 @@ function DataBrowserSidebarContent({
const [optimisticlyRemovedTable, setOptimisticlyRemovedTable] =
useState<string>();
const [selectedSchema, setSelectedSchema] = useState<string>();
const [selectedSchema, setSelectedSchema] = useState<string>('');
const isSelectedSchemaLocked = isSchemaLocked(selectedSchema);
/**

View File

@@ -85,7 +85,7 @@ export default function AuthenticatedLayout({
<BaseLayout {...props}>
<Header className="flex max-h-[59px] flex-auto" />
<Container className="my-12 grid max-w-md grid-flow-row justify-center gap-2 text-center">
<Container className="grid justify-center max-w-md grid-flow-row gap-2 my-12 text-center">
<div className="mx-auto">
<Image
src="/terminal-text.svg"
@@ -123,7 +123,7 @@ export default function AuthenticatedLayout({
}
return (
<BaseLayout className="flex h-full flex-col" {...props}>
<BaseLayout className="flex flex-col h-full" {...props}>
<Modal
showModal={newWorkspace}
close={closeSection}

View File

@@ -1,8 +1,8 @@
import { NhostClient } from '@nhost/nextjs';
const nhost = new NhostClient({
backendUrl: process.env.NEXT_PUBLIC_NHOST_BACKEND_URL as string,
});
export const nhost =
process.env.NEXT_PUBLIC_NHOST_PLATFORM === 'true'
? new NhostClient({ backendUrl: process.env.NEXT_PUBLIC_NHOST_BACKEND_URL })
: new NhostClient({ subdomain: 'localhost' });
export { nhost };
export default nhost;

1
docs/.gitignore vendored
View File

@@ -18,3 +18,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vercel

View File

@@ -1,5 +1,5 @@
---
title: 'Email Templates'
title: Email Templates
sidebar_position: 4
---
@@ -16,7 +16,7 @@ Changing email templates is only available for projects on the [Pro and Enterpri
## Update Email Templates
Your project must be connected to a GitHub repository using the [GitHub Integration](/platform/github-integration) to be able to change the email templates.
Your project must be connected to a [Git Repository](/platform/git) to be able to change the email templates.
Email templates are automatically deployed during a deployment, just like database migrations, Hasura metadata, and Serverless Functions.
@@ -70,7 +70,7 @@ As you see, the format is:
nhost/emails/{two-letter-language-code}/{email-template}/[subject.txt, body.html]
```
Default templates for English (`en`) and French (`fr`) are automatically generated when the project is initialized with the [CLI](/platform/cli).
Default templates for English (`en`) and French (`fr`) are automatically generated when the project is initialized with the [CLI](/cli).
## Languages

View File

@@ -0,0 +1,32 @@
---
title: Authentication
sidebar_label: Overview
sidebar_position: 1
image: /img/og/authentication.png
---
Nhost Authentication is a ready-to-use authentication service that is integrated with the [GraphQL API](/graphql) and its permission system from Hasura.
Nhost Authentication lets you authenticate users using different sign-in methods:
- [Email and Password](/authentication/sign-in-with-email-and-password)
- [Magic Link](/authentication/sign-in-with-magic-link)
- [Phone Number (SMS)](/authentication/sign-in-with-phone-number-sms)
- [Security Keys (WebAuthn)](/authentication/sign-in-with-phone-number-sms)
- [Apple](/authentication/sign-in-with-apple)
- [Discord](/authentication/sign-in-with-discord)
- [Facebook](/authentication/sign-in-with-facebook)
- [GitHub](/authentication/sign-in-with-github)
- [Google](/authentication/sign-in-with-google)
- [LinkedIn](/authentication/sign-in-with-linkedin)
- [Spotify](/authentication/sign-in-with-spotify)
- [Twitch](/authentication/sign-in-with-twitch)
## How it works
1. When a user signs up or is created, the user's information is inserted into the `auth.users` table in your database.
2. Nhost returns an access token and a refresh token, together with the user's information.
3. The user sends requests to Nhost services (GraphQL API, Authentication, Storage, Functions) with the access token as a header.
4. The Nhost services use the user's access token to authorize the requests.
Nhost Autentication is integrated with your [database](/database). All users are stored in the `users` table in the `auth` schema.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Email and Password
sidebar_label: Email and Password
slug: /platform/authentication/sign-in-with-email-and-password
image: /img/og/platform/sign-in-with-email-and-password.png
slug: /authentication/sign-in-with-email-and-password
image: /img/og/sign-in-with-email-and-password.png
---
Follow this guide to sign in users with email and password.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Magic Link
sidebar_label: Magic Link
slug: /platform/authentication/sign-in-with-magic-link
image: /img/og/platform/sign-in-with-magic-link.png
slug: /authentication/sign-in-with-magic-link
image: /img/og/sign-in-with-magic-link.png
---
Follow this guide to sign in users with Magic Link, also called passwordless email.
@@ -13,7 +13,7 @@ The Magic Link sign-in method enables you to sign in users using an email addres
Enable the Magic Link sign-in method in the Nhost dashboard under **Users** -> **Authentication Settings** -> **Magic Link**.
![Magic Link Setup with Nhost](/img/platform/authentication/sign-in-methods/magic-link/magic-link-setup.png)
![Magic Link Setup with Nhost](/img/authentication/magic-link/magic-link-setup.png)
## Sign In
@@ -30,4 +30,4 @@ nhost.auth.signIn({
})
```
If you want to change the email for your magic link emails, you can do so by changing the [email templates](/platform/authentication/email-templates).
If you want to change the email for your magic link emails, you can do so by changing the [email templates](/authentication/email-templates).

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Phone Number (SMS)
sidebar_label: Phone Number (SMS)
slug: /platform/authentication/sign-in-with-phone-number-sms
image: /img/og/platform/sign-in-with-phone-number-sms.png
slug: /authentication/sign-in-with-phone-number-sms
image: /img/og/sign-in-with-phone-number-sms.png
---
Follow this guide to sign in users with a phone number (SMS).

View File

@@ -1,7 +1,7 @@
---
title: Sign In with Security Keys
sidebar_label: Security Keys
slug: /platform/authentication/sign-in-with-security-keys
slug: /authentication/sign-in-with-security-keys
---
Follow this guide to sign in users with security keys and the WebAuthn API.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Apple
sidebar_label: Apple
slug: /platform/authentication/sign-in-with-apple
image: /img/og/platform/sign-in-with-apple.png
slug: /authentication/sign-in-with-apple
image: /img/og/sign-in-with-apple.png
---
Follow this guide to sign in users with Apple.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Discord
sidebar_label: Discord
slug: /platform/authentication/sign-in-with-discord
image: /img/og/platform/sign-in-with-discord.png
slug: /authentication/sign-in-with-discord
image: /img/og/sign-in-with-discord.png
---
Follow this guide to sign in users with Discord.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Facebook
sidebar_label: Facebook
slug: /platform/authentication/sign-in-with-facebook
image: /img/og/platform/sign-in-with-facebook.png
slug: /authentication/sign-in-with-facebook
image: /img/og/sign-in-with-facebook.png
---
Follow this guide to sign in users with Facebook.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with GitHub
sidebar_label: GitHub
slug: /platform/authentication/sign-in-with-github
image: /img/og/platform/sign-in-with-github.png
slug: /authentication/sign-in-with-github
image: /img/og/sign-in-with-github.png
---
Follow this guide to sign in users with GitHub.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Google
sidebar_label: Google
slug: /platform/authentication/sign-in-with-google
image: /img/og/platform/sign-in-with-google.png
slug: /authentication/sign-in-with-google
image: /img/og/sign-in-with-google.png
---
Follow this guide to sign in users with Google.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with LinkedIn
sidebar_label: LinkedIn
slug: /platform/authentication/sign-in-with-linkedin
image: /img/og/platform/sign-in-with-linkedin.png
slug: /authentication/sign-in-with-linkedin
image: /img/og/sign-in-with-linkedin.png
---
Follow this guide to sign in users with LinkedIn.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Spotify
sidebar_label: Spotify
slug: /platform/authentication/sign-in-with-spotify
image: /img/og/platform/sign-in-with-spotify.png
slug: /authentication/sign-in-with-spotify
image: /img/og/sign-in-with-spotify.png
---
Follow this guide to sign in users with Spotify.

View File

@@ -1,8 +1,8 @@
---
title: Sign In with Twitch
sidebar_label: Twitch
slug: /platform/authentication/sign-in-with-twitch
image: /img/og/platform/sign-in-with-twitch.png
slug: /authentication/sign-in-with-twitch
image: /img/og/sign-in-with-twitch.png
---
Follow this guide to sign in users with Twitch.

View File

@@ -0,0 +1,24 @@
---
title: 'Sign-In Methods'
slug: /authentication/sign-in-methods
image: /img/og/sign-in-methods.png
---
Nhost Authentication supports the following sign-in methods:
- [Email and Password](/authentication/sign-in-with-email-and-password)
- [Magic Link](/authentication/sign-in-with-magic-link)
- [Phone Number (SMS)](/authentication/sign-in-with-phone-number-sms)
- [Security Keys (WebAuthn)](/authentication/sign-in-with-phone-number-sms)
- [Apple](/authentication/sign-in-with-apple)
- [Discord](/authentication/sign-in-with-discord)
- [Facebook](/authentication/sign-in-with-facebook)
- [GitHub](/authentication/sign-in-with-github)
- [Google](/authentication/sign-in-with-google)
- [LinkedIn](/authentication/sign-in-with-linkedin)
- [Spotify](/authentication/sign-in-with-spotify)
- [Twitch](/authentication/sign-in-with-twitch)
## Enabling sign-in methods during local development
To enable a sign-in method locally, add variables corresponding to the relevant authentication methods in an `.env.development` file located in the project repository. An overview of available options is available in the [Hasura Auth repository](https://github.com/nhost/hasura-auth/blob/main/docs/environment-variables.md#oauth-environment-variables).

View File

@@ -2,7 +2,7 @@
title: Tokens
sidebar_label: Tokens
sidebar_position: 10
image: /img/og/platform/tokens.png
image: /img/og/tokens.png
---
Nhost Authentication makes use of two types of tokens:
@@ -51,7 +51,7 @@ The decoded payload of this access token is a JSON object that looks like this:
The token contains information about the user id, default role, allowed roles, if the user is anonymous or not, and other metadata.
The claims under `https://hasura.io/jwt/claims` are the same claims that are used by the GraphQL API to create [permissions](/platform/graphql/permissions). The claims (`x-hasura-*`) are also called permission variables. It's possible to add custom [permission variables](/platform/graphql/permissions#custom-permission-variables).
The claims under `https://hasura.io/jwt/claims` are the same claims that are used by the GraphQL API to create [permissions](/graphql/permissions). The claims (`x-hasura-*`) are also called permission variables. It's possible to add custom [permission variables](/graphql/permissions#custom-permission-variables).
:::info
You can manually decode an access token using [JWT.io](https://jwt.io/).
@@ -60,7 +60,7 @@ You can manually decode an access token using [JWT.io](https://jwt.io/).
The token is cryptographically signed by Nhost Authentication, which means that all other Nhost services can trust the information in the token.
:::info
Use the `NHOST_JWT_SECRET` [system environment variable](/platform/environment-variables#system-environment-variables) to verify access tokens in [Serverless Functions](/platform/serverless-functions). Here's a guide on how to [Get the authenticated user in a Serverless Function](https://github.com/nhost/nhost/discussions/278).
Use the `NHOST_JWT_SECRET` [system environment variable](/platform/environment-variables#system-environment-variables) to verify access tokens in [Serverless Functions](/serverless-functions). Here's a guide on how to [Get the authenticated user in a Serverless Function](https://github.com/nhost/nhost/discussions/278).
:::
The access token can not be revoked. Instead, the token is only valid for 15 minutes. The user can get a new access token by using the refresh token.

View File

@@ -2,7 +2,7 @@
title: Users
sidebar_label: Users
sidebar_position: 1
image: /img/og/platform/users.png
image: /img/og/users.png
---
Users are stored in the database in the `users` table in the `auth` schema.
@@ -37,7 +37,7 @@ query {
## Creating Users
Users should be created using the sign-up or sign-in flows as described under [sign-in methods](/platform/authentication/sign-in-methods).
Users should be created using the sign-up or sign-in flows as described under [sign-in methods](/authentication/sign-in-methods).
- **Never** create users directly via GraphQL or database, unless you [import users](#import-users) from an external system.
- **Never** modify the `auth.users` table.

View File

@@ -0,0 +1,4 @@
{
"label": "CLI",
"position": 9
}

View File

@@ -1,30 +1,32 @@
---
title: 'CLI'
sidebar_position: 11
image: /img/og/platform/cli.png
title: Nhost CLI
sidebar_label: Overview
sidebar_position: 1
image: /img/og/cli.png
---
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 projects locally on Mac, Linux and Windows (WSL2).
Nhost CLI, or `nhost`, is a command-line interface that lets you run and manage Nhost projects locally on Mac, Linux, and Windows (WSL2).
This means you get a full-featured Nhost project running locally on your machine:
- Postgres Database
- Hasura GraphQL API
- Hasura Console
- Auth
- Authentication
- Storage
- Serverless Functions
This way, you can develop and test local changes before you deploy them live. The CLI automatically tracks:
This way, you can develop and test local changes before you deploy them. The CLI automatically tracks:
- Postgres database migrations
- Hasura metadata
- Serverless functions
- Postgres Database Migrations
- Hasura Metadata
- [Serverless Functions](/serverless-functions)
- [Email Templates](/authentication/email-templates)
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.
It's recommended to use [Git](/platform/git) for Nhost to automatically deploy changes to your Nhost project on `git push`.
## Installation
@@ -95,7 +97,7 @@ const nhost = new NhostClient({
## Emails
During local development with the CLI, all transactional emails from Nhost Auth are sent to a local Mailhog instance, instead of to the recipient's email address.
During local development with the CLI, all transactional emails from Nhost Authentication are sent to a local Mailhog services, instead of to the recipient's email address.
The Mailhog address is listed after starting [`nhost up`](/reference/cli/up):
@@ -119,5 +121,5 @@ URLs:
## What's next?
- Read our in-depth guide on [Get started with Nhost CLI](/platform/overview/get-started-with-nhost-cli)
- Read our in-depth guide on [Development with the Nhost CLI](/cli/local-development)
- [CLI commands reference](/reference/cli)

View File

@@ -1,18 +1,15 @@
---
title: 'Get Started with Nhost CLI'
title: 'Local Development'
sidebar_label: 'Local Development'
sidebar_position: 2
image: /img/og/platform/get-started-with-nhost-cli.png
image: /img/og/get-started-with-nhost-cli.png
---
# 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).
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
### Install the Nhost CLI
To install **Nhost CLI**, run this command from any directory in your terminal:
@@ -20,84 +17,54 @@ To install **Nhost CLI**, run this command from any directory in your terminal:
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`.
The Nhost CLI works for MacOS, Linux, and Windows WSL2.
If you'd prefer to install to a different location other than `/usr/local/bin`,
set the `INSTALL_PATH` variable accordingly:
The Nhost CLI is installed at `/usr/local/bin`.
<!-- On **MacOS, Linux, and Windows (WSL2)**, this will install the **Nhost CLI** in `/usr/local/bin`. -->
If you'd prefer to install the CLI at 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.
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:
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:
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
### Nhost CLI login
After installing **Nhost CLI**, you can log in to your Nhost account by running
the following command:
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).
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/).
If you've signed up with GitHub you must first set a new password in the [Nhost Dashboard](https://app.nhost.io/) to use to sign in with the Nhost CLI.
:::
![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.
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
## Set Up Your Project
### 1. Create a new Nhost project
@@ -105,22 +72,17 @@ import CreateProject from '@site/src/components/create-nhost-project.mdx'
<CreateProject />
### 2. Create a new GitHub Repository
### 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.
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.
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
### 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 new commits to your connected Git repository.
Finally, connect your GitHub repository to your Nhost project. Doing so will enable Nhost to deploy new versions of your project when you push new commits to your connected Git repository.
1. From your project workspace, click **Connect to GitHub**.
@@ -134,16 +96,13 @@ enable Nhost to deploy new versions of your project when you push new commits to
![Connect to GitHub](/img/architecture/cli/connect-repo-step-3.png)
## Develop locally
## Local Development
## 1. Initialize your Nhost project
## 1. Initialize your Nhost Project
**Nhost CLI** brings the functionality of your Nhost production environment
directly to your local machine.
**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 environment in a local environment. That way, you can make changes
and test your code locally before deploying those changes to production.
It provides Docker containers to run the backend services that match your production environment in a local environment. That way, you can make changes and test your code locally before deploying those changes to production.
Initialize your Nhost project locally with the following command:
@@ -167,8 +126,7 @@ my-nhost-app/
└─ seeds/
```
Finally, make sure to link your current working directory to your GitHub
repository:
Finally, make sure to link your current working directory to your GitHub repository:
```bash
echo "# my-nhost-app" >> README.md
@@ -182,54 +140,59 @@ git push -u origin main
## 2. Start a local development environment
To start a local development environment for your Nhost project, run the following
command:
To start a local development environment for your Nhost project, run the following command:
```bash
nhost up
```
:::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 test the GraphQL API.
:::info
Here are two tips when using the Nhost CLI:
1. Use `nhost up -d` to run the Nhost CLI in debug mode for more verbose output.
2. Use `nhost logs -f` in a different terminal to see local logs for your Nhost project.
:::
`nhost up` starts Hasura Console for the GraphQL Engine so you can manage the database and test the GraphQL API.
The Hasura Console opens automatically at [http://localhost:9695](http://localhost:9695/).
![Hasura Console](/img/architecture/cli/hasura-console.png)
## 3. Make changes
## 3. Make Changes
There are three things the Nhost CLI and the GitHub integration track and apply
to production:
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.
Settings in `nhost/config.yaml` are **not** deployed. That means you need to manually sync settings between local and remote environments between the CLI and Nhost Cloud.
:::
### Database migrations
### Database Migrations
Database changes are tracked and managed through migrations.
Database changes are automatically tracked and managed through migrations.
:::tip
You must use the Hasura Console to make database changes. With the Hasura Console, database migration files are automatically generated incrementally to track database changes for you.
:::
To demonstrate how to make database changes, let's create a new table called
`messages`, with the following columns:
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, go to the **DATA** tab section and click on the
PostgreSQL database (from the left side navigation) that Nhost provides us.

View File

@@ -1,7 +1,7 @@
---
title: 'Event triggers'
sidebar_position: 2
image: /img/og/platform/event-triggers.png
image: /img/og/event-triggers.png
---
Event Triggers enable you to invoke webhooks when a database event happens. Event Triggers are typically used to do post-processing tasks, using custom backend code, based on database events.
@@ -34,7 +34,7 @@ Event Triggers are managed in the Hasura Console. Select **Events** in the main
## Event Triggers and Serverless Functions
Event Triggers and [Serverless Functions](/platform/serverless-functions) is a perfect combination to build powerful database-backend logic. Every Serverless Function is exposed as an HTTP endpoint and can be used as a webhook for Event Triggers.
Event Triggers and [Serverless Functions](/serverless-functions) are a perfect combination to build powerful database-backend logic. Every Serverless Function is exposed as an HTTP endpoint and can be used as a webhook for Event Triggers.
### Format
@@ -46,13 +46,13 @@ When using Serverless Functions as webhooks you should configure the webhook usi
![Webhook URL Format](/img/database/event-triggers/webhook-url-format.png)
The `NHOST_BACKEND_URL` is a [system environment variable](/platform/environment-variables#system-environment-variables) and available in production and in development environments using the [CLI](/platform/cli).
The `NHOST_BACKEND_URL` is a [system environment variable](/platform/environment-variables#system-environment-variables) and available in production and in development environments using the [CLI](/cli).
### Security
To make sure incoming requests to your webhook comes from Hasura, and not some malicious third party, you can use a shared webhook secret between Hasura and your webhook handler (e.g. your Serverless Function).
It is recommended to use the `NHOST_WEBHOOK_SECRET`, which is a [system environment variable](/platform/environment-variables#system-environment-variables) and available in production and in development environments using the [CLI](/platform/cli). The `NHOST_WEBHOOK_SECRET` is available both in Hasura and in every Serverless Function.
It is recommended to use the `NHOST_WEBHOOK_SECRET`, which is a [system environment variable](/platform/environment-variables#system-environment-variables) and available in production and in development environments using the [CLI](/cli). The `NHOST_WEBHOOK_SECRET` is available both in Hasura and in every Serverless Function.
To set this up is a two-step process:
@@ -85,9 +85,9 @@ export default async function handler(req, res) {
}
```
The `NHOST_WEBHOOK_SECRET` is a [system environment variable](/platform/environment-variables#system-environment-variables) and available in production and in development environments using the [CLI](/platform/cli).
The `NHOST_WEBHOOK_SECRET` is a [system environment variable](/platform/environment-variables#system-environment-variables) and available in production and in development environments using the [CLI](/cli).
## Next Steps
- Read the full [Event Triggers documentation from Hasura](https://hasura.io/docs/latest/graphql/core/event-triggers/index/).
- Learn about the [GraphQL API](/platform/graphql).
- Learn about the [GraphQL API](/graphql).

View File

@@ -1,7 +1,8 @@
---
title: 'Database'
sidebar_position: 1
image: /img/og/platform/database.png
sidebar_label: 'Overview'
image: /img/og/database.png
---
import Tabs from '@theme/Tabs'
@@ -19,7 +20,7 @@ There are three ways of managing your database:
Generally, you should use the `public` schema for your project. It's also ok to add custom schemas for more advanced usage.
The two schemas `auth` and `storage` are reserved for [Nhost Auth](/platform/authentication) and [Nhost Storage](/platform/storage). You're allowed to modify **permissions** and **add relationships**. However, never modify any tables or remove relationships that were added by Nhost inside the `auth` and `storage` schemas.
The two schemas `auth` and `storage` are reserved for [Nhost Auth](/authentication) and [Nhost Storage](/storage). You're allowed to modify **permissions** and **add relationships**. However, never modify any tables or remove relationships that were added by Nhost inside the `auth` and `storage` schemas.
## Manage Tables
@@ -34,7 +35,7 @@ The two schemas `auth` and `storage` are reserved for [Nhost Auth](/platform/aut
7. (Optional) Add **Foreign Keys**.
8. Click **Create**.
When a table is created it is instantly available through the [GraphQL API](/platform/graphql).
When a table is created it is instantly available through the [GraphQL API](/graphql).
Here's an example of how to create a `customers` table:
@@ -139,17 +140,17 @@ It's possible to reset the database password that was provided when the project
## Migrations
To track database changes, use the [Nhost CLI](/platform/cli) to develop locally and use our [GitHub integration](/platform/github-integration) to automatically deploy database migrations live.
To track database changes, use the [Nhost CLI](/cli) to develop locally and use our [Git integration](/platform/git) to automatically deploy database migrations live.
1. Develop locally using the Nhost CLI.
2. Push changes to GitHub.
3. Nhost automatically deploys changes.
Learn how to [get started with Nhost CLI](/platform/overview/get-started-with-nhost-cli).
Learn how to do [development with the Nhost CLI](/cli/local-development).
## Seed Data
Seed data is a way of automatically adding data to your database using SQL when a new environment is created. This is, for the moment, only applicable when you're using the [Nhost CLI](/platform/cli) to develop locally. When you're running `nhost up` for the first time, seed data is added.
Seed data is a way of automatically adding data to your database using SQL when a new environment is created. This is, for the moment, only applicable when you're using the [Nhost CLI](/cli) to develop locally. When you're running `nhost up` for the first time, seed data is added.
In the future, seed data will also be added to new preview environments.
@@ -177,4 +178,4 @@ Databases on the [Pro and Enterprise plans](https://nhost.io/pricing) are automa
- [Learn PostgreSQL Tutorial - Full Course for Beginners (YouTube)](https://www.youtube.com/watch?v=qw--VYLpxG4).
- Learn more about how to manage your [Postgres database in Hasura](https://hasura.io/docs/latest/graphql/core/databases/postgres/schema/index/).
- Learn about the [GraphQL API](/platform/graphql).
- Learn about the [GraphQL API](/graphql).

View File

@@ -1,10 +1,11 @@
---
title: 'GraphQL API'
sidebar_position: 1
image: /img/og/platform/graphql.png
sidebar_label: 'Overview'
image: /img/og/graphql.png
---
A GraphQL API is automatically and instantly available based on the tables and columns in your [database](/platform/database).
A GraphQL API is automatically and instantly available based on the tables and columns in your [database](/database).
The GraphQL API has support for inserting, selecting, updating, and deleting data, which usually accounts for 80% of all API operations you need.
@@ -20,7 +21,7 @@ Building your GraphQL API is a lot of work, but with Nhost it's easy because eve
## Endpoint
The GraphQL API is available at `https://[subdomain].nhost.run/v1/graphql` When using the [CLI](/platform/cli) the GraphQL API is available at `http://localhost:1337/v1/graphql`.
The GraphQL API is available at `https://[subdomain].nhost.run/v1/graphql` When using the [CLI](/cli) the GraphQL API is available at `http://localhost:1337/v1/graphql`.
## GraphQL Clients for JavaScript

View File

@@ -1,7 +1,7 @@
---
title: 'Permissions'
sidebar_position: 1
image: /img/og/platform/permissions.png
image: /img/og/permissions.png
---
The GraphQL API is protected by a role-based permission system.
@@ -30,7 +30,7 @@ The rule above make it so users can only select posts where the value of `user_i
## What is `x-hasura-user-id`?
`x-hasura-user-id` is a permission variable that is used to create permission rules in Hasura. The permission variable comes from the [access token](platform/authentication#access-tokens) that signed-in users have.
`x-hasura-user-id` is a permission variable that is used to create permission rules in Hasura. The permission variable comes from the [access token](/authentication#access-tokens) that signed-in users have.
The `x-hasura-user-id` permission variable is always available for all signed-in users. You can add [custom permission variables](#custom-permission-variables) to create more complex permission rules unique to your project.
@@ -38,7 +38,7 @@ The `x-hasura-user-id` permission variable is always available for all signed-in
You can add custom permission variables in the Nhost console under **Users** and then **Roles and permissions**. These permission variables are then available when creating permissions for your GraphQL API in the Hasura console.
![Permission Variables](/img/platform/permission-variables-preview.svg)
![Permission Variables](/img/permission-variables-preview.svg)
**Example:**: Let's say you add a new permission variable `x-hasura-organisation-id` with path `user.profile.organisation.id`. This means that Nhost Auth will get the value for `x-hasura-organisation-id` by internally generating the following GraphQL query:
@@ -128,7 +128,7 @@ Now, users who are signed-in can insert posts. Users can add a title when insert
Select, update, and delete permissions usually follows the same pattern. Here's an example of how to add select permissions:
![Select permissions](/img/platform/permission-select.png)
![Select permissions](/img/permission-select.png)
One of the most common permission requirements is that signed-in users should only be able to read their own data. This is how to do that:

View File

@@ -1,8 +1,7 @@
---
title: 'Introduction to Nhost'
sidebar_label: Introduction
sidebar_position: 1
image: /img/og/platform/introduction-to-nhost.png
image: /img/og/introduction-to-nhost.png
---
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.
@@ -15,17 +14,44 @@ We make it easy to build and deploy this backend using our platform which takes
Get started quickly by following one of our quickstart guides:
- [Next.js](/platform/quickstarts/nextjs)
- [React](/platform/quickstarts/react)
- [RedwoodJS](/platform/quickstarts/redwoodjs)
- [Vue](/platform/quickstarts/vue)
- [Next.js](/quickstarts/nextjs)
- [React](/quickstarts/react)
- [RedwoodJS](/quickstarts/redwoodjs)
- [Vue](/quickstarts/vue)
## Products and Features
Learn more about the product and features of Nhost.
- [Database](/platform/database)
- [GraphQL API](/platform/graphql)
- [Authentication](/platform/authentication)
- [Storage](/platform/storage)
- [Serverless Functions](/platform/serverless-functions)
- [Database](/database)
- [GraphQL API](/graphql)
- [Authentication](/authentication)
- [Storage](/storage)
- [Serverless Functions](/serverless-functions)
## Architecture
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 API (`/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 API: [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,57 @@
---
title: 'Introduction to Nhost'
sidebar_label: Introduction
image: /img/og/introduction-to-nhost.png
---
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 which takes care of configuration, security, and performance. Things just work and scale automatically so you can focus on your product and your business.
## Quickstart
Get started quickly by following one of our quickstart guides:
- [Next.js](/quickstarts/nextjs)
- [React](/quickstarts/react)
- [RedwoodJS](/quickstarts/redwoodjs)
- [Vue](/quickstarts/vue)
## Products and Features
Learn more about the product and features of Nhost.
- [Database](/database)
- [GraphQL API](/graphql)
- [Authentication](/authentication)
- [Storage](/storage)
- [Serverless Functions](/serverless-functions)
## Architecture
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 API (`/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 API: [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,4 @@
{
"label": "Platform",
"position": 10
}

View File

@@ -1,32 +0,0 @@
---
title: Nhost Authentication
sidebar_label: Authentication
sidebar_position: 1
image: /img/og/platform/authentication.png
---
Nhost Authentication is a ready-to-use authentication service that is integrated with the [GraphQL API](/platform/graphql) and its permission system from Hasura.
Nhost Authentication lets you authenticate users using different sign-in methods:
- [Email and Password](/platform/authentication/sign-in-with-email-and-password)
- [Magic Link](/platform/authentication/sign-in-with-magic-link)
- [Phone Number (SMS)](/platform/authentication/sign-in-with-phone-number-sms)
- [Security Keys (WebAuthn)](/platform/authentication/sign-in-with-phone-number-sms)
- [Apple](/platform/authentication/sign-in-with-apple)
- [Discord](/platform/authentication/sign-in-with-discord)
- [Facebook](/platform/authentication/sign-in-with-facebook)
- [GitHub](/platform/authentication/sign-in-with-github)
- [Google](/platform/authentication/sign-in-with-google)
- [LinkedIn](/platform/authentication/sign-in-with-linkedin)
- [Spotify](/platform/authentication/sign-in-with-spotify)
- [Twitch](/platform/authentication/sign-in-with-twitch)
## How it works
1. When a user signs up or is created, the user's information is inserted into the `auth.users` table in your database.
2. Nhost returns an access token and a refresh token, together with the user's information.
3. The user sends requests to Nhost services (GraphQL API, Authentication, Storage, Functions) with the access token as a header.
4. The Nhost services use the user's access token to authorize the requests.
Nhost's authentication service is integrated with your database. All users are stored in the `users` table under the `auth` schema.

View File

@@ -1,24 +0,0 @@
---
title: 'Sign-In Methods'
slug: /platform/authentication/sign-in-methods
image: /img/og/platform/sign-in-methods.png
---
Nhost Authentication support the following sign-in methods:
- [Email and Password](/platform/authentication/sign-in-with-email-and-password)
- [Magic Link](/platform/authentication/sign-in-with-magic-link)
- [Phone Number (SMS)](/platform/authentication/sign-in-with-phone-number-sms)
- [Security Keys (WebAuthn)](/platform/authentication/sign-in-with-phone-number-sms)
- [Apple](/platform/authentication/sign-in-with-apple)
- [Discord](/platform/authentication/sign-in-with-discord)
- [Facebook](/platform/authentication/sign-in-with-facebook)
- [GitHub](/platform/authentication/sign-in-with-github)
- [Google](/platform/authentication/sign-in-with-google)
- [LinkedIn](/platform/authentication/sign-in-with-linkedin)
- [Spotify](/platform/authentication/sign-in-with-spotify)
- [Twitch](/platform/authentication/sign-in-with-twitch)
## Enabling sign-in methods during local development
To enable a sign-in method locally, add variables corresponding to the relevant authentication methods in an `.env.development` file located in the project repository. An overview of available options is available over in the [hasura auth repository](https://github.com/nhost/hasura-auth/blob/main/docs/environment-variables.md#oauth-environment-variables).

View File

@@ -1,6 +1,6 @@
---
title: 'Environment Variables'
sidebar_position: 9
sidebar_position: 2
image: /img/og/platform/environment-variables.png
---
@@ -10,16 +10,16 @@ You can manage your project's Environment Variables in Nhost Dashboard under **V
![Environment Variables](/img/platform/environment-variables/environment-variables.png)
When an Environment Variable is changed, you must deploy your project again using the [GitHub integration](/platform/github-integration) for the changes to take effect.
Environment Variables are available for:
Environment Variables are available in:
- [Hasura GraphQL Engine](/graphql)
- [Serverless Functions](/serverless-functions)
- Hasura
- Serverless Functions
When an Environment Variable has updated the changes happen immediately for Hasura GraphQL Engine. For Serverless Functions, a new deployment via [Git](/platform/git) is required.
## System Environment Variables
System Environment Variables are automatically available in production and during development. The following system Environment Variables are available:
System Environment Variables are automatically available in production and during local development. The following system Environment Variables are available:
- `NHOST_ADMIN_SECRET`
- `NHOST_WEBHOOK_SECRET`
@@ -38,7 +38,7 @@ NHOST_BACKEND_URL=https://xxxxxxx.nhost.run
## Development Environment Variables
When developing locally using the [CLI](/platform/cli), Environment Variables set in `.env.development` are available in your local environment. There are two ways to manage them:
When developing locally using the [CLI](/cli), Environment Variables set in `.env.development` are available in your local environment. There are two ways to manage them:
1. Edit the `.env.development` file manually.
2. Add development Environment Variables in the Nhost Dashboard and use `nhost env pull` to sync them. This way, your team members will also have access to the same Environment Variables.

View File

@@ -1,12 +1,18 @@
---
title: 'GitHub Integration'
sidebar_position: 10
title: 'Git'
sidebar_position: 1
image: /img/og/platform/github-integration.png
---
The GitHub integration allows you to automatically deploy your Nhost project when on push and merge to a GitHub repository that is connected to your Nhost project.
Nhost allows you to automatically deploy your Nhost project when you do changes to your Git repository.
When a GitHub repository is connected to a Nhost project, Nhost automatically deploys changes when you push code to the repo.
## Supported Git Providers
- GitHub
Support GitLab, BitBucket, and other Git providers are on our roadmap.
## How It Works
The following things are deployed:
@@ -18,11 +24,11 @@ The following things are deployed:
Settings in `nhost/config.yaml` are **not** deployed. That means you need to manually sync settings between local and remote environments between the CLI and Nhost Cloud.
:::
## Connecting a GitHub repository
## Using GitHub
1. From your Nhost project, click **Connect to Github**.
![Connect to GitHub](/img/architecture/cli/connect-repo-step-1.png)
![Connect to GitHub](/img/platform/git/connect-to-github.png)
2. **Install the Nhost project** on your Github account.
@@ -41,7 +47,7 @@ You can change the deployment branch by clicking **Edit** next to the repository
You can have multiple Nhost projects connected to the same GitHub repository and use different deployment branches (e.g., `main` and `staging`).
<center>
<img src="/img/platform/github-integration/deployment-branch.png" alt="drawing" width="50%" />
<img src="/img/github-integration/deployment-branch.png" alt="drawing" width="50%" />
</center>
## Base Directory
@@ -49,9 +55,5 @@ You can have multiple Nhost projects connected to the same GitHub repository and
If your Nhost project is not at the root of your git repository (typically when using a monorepo), you can set a custom base directory. The base directory is where the `nhost` directory is located. In other words, the base directory is the **parent directory** of the `nhost` folder.
<center>
<img src="/img/platform/github-integration/base-directory.png" alt="drawing" width="50%" />
<img src="/img/github-integration/base-directory.png" alt="drawing" width="50%" />
</center>
## Next Steps
- Learn how to [use the CLI to deploy your Nhost project](/platform/overview/get-started-with-nhost-cli).

View File

@@ -0,0 +1,50 @@
---
title: 'Multiple Environments'
sidebar_position: 3
---
Here's a guide on how to use Nhost with multiple environments and how to set up a workflow around them.
For this example, we'll set up one **production environment** and one **staging environment**.
## Git
Create a new Git repo and use the [CLI](/cli) and the `nhost init` command to initialize a new project.
Also, create a new branch called `staging`.
You should now have a Git repo with a `main` branch and a `staging` branch.
## Nhost Cloud
To have two environments, we need to create two projects on Nhost Cloud.
Both projects must be connected to the **same** [Git](/platform/git) repo, but using **different** [deployment branches](/platform/git#deployment-branch).
Set your production project to use the `main` branch as the Deployment Branch and your staging project to use the `staging` branch as the Deployment Branch. This way, the production project will only deploy new changes to the `main` branch and the staging project will only deploy new changes to the `staging` branch.
<center>
<img src="/img/github-integration/deployment-branch.png" alt="drawing" width="50%" />
</center>
## Development
### Local
Now, use the CLI to do [local development](/cli/local-development). And use a specific feature branch while doing development.
### Staging
Once you're ready to test your changes to staging, create a pull request from your feature branch to the `staging` branch. Then, merge the pull request to `staging`.
This will automatically trigger a new deployment to the staging project on the Nhost platform.
### Production
Once you've tested your changes in the staging environment, you can create a new pull request from the `staging` branch to the `main` branch. Then, merge the pull request to `main`.
This will automatically trigger a new deployment to the production project on the Nhost platform.
## Summary
Now you have two environments, one for staging and one for production. You can use this workflow to do local development, and test your changes in a staging environment before deploying them to production.

View File

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

View File

@@ -1,30 +0,0 @@
---
title: 'Architecture'
sidebar_position: 2
image: /img/og/platform/architecture.png
---
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

@@ -2,7 +2,7 @@
title: 'Quickstart: Next.js'
sidebar_label: Next.js
sidebar_position: 2
image: /img/og/platform/quickstart-nextjs.png
image: /img/og/quickstart-nextjs.png
---
import Tabs from '@theme/Tabs'
@@ -39,7 +39,7 @@ import CreateApp from '@site/src/components/create-nhost-project.mdx'
<CreateApp />
:::info
You can also connect your Nhost project 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).
You can also connect your Nhost project to a Git repository at GitHub. When you do this, any updates you push to your code will automatically be deployed. [Learn more](/platform/git)
:::
## Initialize the app
@@ -168,7 +168,7 @@ file to load your new environment variable.
:::
:::info Nhost CLI
Do you use the Nhost CLI? Learn how to set `subdomain` and `region` in the [CLI documentation](/platform/cli#subdomain-and-region).
Do you use the Nhost CLI? Learn how to set `subdomain` and `region` in the [CLI documentation](/cli#subdomain-and-region).
:::
## Build the app

View File

@@ -2,7 +2,7 @@
title: 'Quickstart: React'
sidebar_label: React
sidebar_position: 1
image: /img/og/platform/quickstart-react.png
image: /img/og/quickstart-react.png
---
import Tabs from '@theme/Tabs'
@@ -39,7 +39,7 @@ import CreateProject from '@site/src/components/create-nhost-project.mdx'
<CreateProject />
:::info
You can also connect your Nhost project 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).
You can also connect your Nhost project to a Git repository at GitHub. When you do this, any updates you push to your code will automatically be deployed. [Learn more](/platform/git)
:::
## Initialize the app
@@ -162,7 +162,7 @@ file to load your new environment variable.
:::
:::info Nhost CLI
Do you use the Nhost CLI? Learn how to set `subdomain` and `region` in the [CLI documentation](/platform/cli#subdomain-and-region).
Do you use the Nhost CLI? Learn how to set `subdomain` and `region` in the [CLI documentation](/cli#subdomain-and-region).
:::
## Build the app

View File

@@ -2,7 +2,7 @@
title: 'Quickstart: RedwoodJS'
sidebar_label: RedwoodJS
sidebar_position: 3
image: /img/og/platform/quickstart-redwoodjs.png
image: /img/og/quickstart-redwoodjs.png
---
import Tabs from '@theme/Tabs'
@@ -54,7 +54,7 @@ Finally, update your client login URL from your Nhost dashboard as the local Red
![nhost-first-app](/img/quickstarts/create-app-step-3.png)
:::info
You can also connect your Nhost project 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).
You can also connect your Nhost project to a Git repository at GitHub. When you do this, any updates you push to your code will automatically be deployed. [Learn more](/platform/git)
:::
## Initialize the app

View File

@@ -2,7 +2,7 @@
title: 'Quickstart: Vue'
sidebar_label: Vue
sidebar_position: 3
image: /img/og/platform/quickstart-vue.png
image: /img/og/quickstart-vue.png
---
import Tabs from '@theme/Tabs'
@@ -45,7 +45,7 @@ import CreateApp from '@site/src/components/create-nhost-project.mdx'
<CreateApp />
:::info
You can also connect your Nhost project 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).
You can also connect your Nhost project to a Git repository at GitHub. When you do this, any updates you push to your code will automatically be deployed. [Learn more](/platform/git)
:::
## Initialize the app
@@ -184,7 +184,7 @@ You find your Nhost project's `subdomain` and `region` in the [project overview]
![Project Overview](/img/quickstarts/app-dashboard.png)
:::info Nhost CLI
Do you use the Nhost CLI? Learn how to set `subdomain` and `region` in the [CLI documentation](/platform/cli#subdomain-and-region).
Do you use the Nhost CLI? Learn how to set `subdomain` and `region` in the [CLI documentation](/cli#subdomain-and-region).
:::
## Build the app

View File

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

View File

@@ -3,7 +3,7 @@ title: 'init'
sidebar_position: 1
---
Initialize a local Nhost project in the current working directory.
Initialize a local Nhost project.
```
nhost init
@@ -11,8 +11,8 @@ nhost init
If you already have a Nhost project in Nhost Cloud you can use that project as a starting point by appending `--remote` to the command.
This will pull the database migrations and Hasura metadata from the Nhost Cloud project locally for you to use as a starting point.
```
nhost init --remote
```
This will reset the local database migrations and Hasura metadata, and pull the database migrations and Hasura metadata from the Nhost Cloud project locally for you to use as a starting point. While doing `nhost init --remote` it's also recommended to setup [Git](/platform/git) to activate automated deplouments on `git push` for your Nhost project.

View File

@@ -7,8 +7,13 @@ Launch the development environment for your project. Once the environment is up,
- Apply database migrations.
- Apply the Hasura metadata.
- Apply [seed data](/platform/database#seed-data).
```bash
nhost up
```
If it's the first time you start the project, [seed data](/database#seed-data) will be applied.
## Stop
Use `ctrl+c` to stop the development environment.

View File

@@ -4,7 +4,7 @@ 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#L108
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L117
---
# `signUp()`
@@ -25,3 +25,25 @@ nhost.auth.signUp({
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`SignUpParams`](/reference/docgen/javascript/auth/types/sign-up-params)
---
## Examples
### Sign up with an email and password
```ts
nhost.auth.signUp({
email: 'joe@example.com',
password: 'secret-password'
})
```
### Sign up with a security key
```ts
nhost.auth.signUp({
email: 'joe@example.com',
securityKey: true
})
@docs https://docs.nhost.io/reference/javascript/auth/sign-up
```

View File

@@ -4,7 +4,7 @@ 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#L170
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L187
---
# `signIn()`
@@ -71,3 +71,14 @@ nhost.auth.signUp({
password: 'secret-password'
})
```
### Sign in with a security key
```ts
nhost.auth.signIn({
email: 'joe@example.com',
securityKey: true
})
@docs https://docs.nhost.io/reference/javascript/auth/sign-in
```

View File

@@ -4,7 +4,7 @@ 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#L270
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L287
---
# `signOut()`

View File

@@ -4,7 +4,7 @@ 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#L286
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L303
---
# `resetPassword()`

View File

@@ -4,7 +4,7 @@ title: changePassword()
sidebar_label: changePassword()
slug: /reference/javascript/auth/change-password
description: Use `nhost.auth.changePassword` to change the password for the signed-in user. The old password is not needed. In case the user is not signed-in, a password reset ticket needs to be provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L302
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L319
---
# `changePassword()`

View File

@@ -4,7 +4,7 @@ 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#L321
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L338
---
# `sendVerificationEmail()`

View File

@@ -4,7 +4,7 @@ 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#L340
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L357
---
# `changeEmail()`

View File

@@ -4,7 +4,7 @@ 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#L356
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L373
---
# `deanonymize()`

View File

@@ -4,7 +4,7 @@ title: addSecurityKey()
sidebar_label: addSecurityKey()
slug: /reference/javascript/auth/add-security-key
description: Use `nhost.auth.addSecurityKey to add a security key to the user, using the WebAuthn API.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L394
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L411
---
# `addSecurityKey()`

View File

@@ -4,7 +4,7 @@ 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#L412
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L429
---
# `onTokenChanged()`

View File

@@ -4,7 +4,7 @@ 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#L447
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L464
---
# `onAuthStateChanged()`

View File

@@ -4,7 +4,7 @@ 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#L489
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L506
---
# `isAuthenticated()`

View File

@@ -4,7 +4,7 @@ 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#L510
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L527
---
# `isAuthenticatedAsync()`

View File

@@ -4,7 +4,7 @@ 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#L538
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L555
---
# `getAuthenticationStatus()`

View File

@@ -4,7 +4,7 @@ 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#L575
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L592
---
# `getAccessToken()`

View File

@@ -4,7 +4,7 @@ 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#L590
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L607
---
# `getDecodedAccessToken()`

View File

@@ -4,7 +4,7 @@ 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#L607
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L624
---
# `getHasuraClaims()`

View File

@@ -4,7 +4,7 @@ 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#L625
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L642
---
# `getHasuraClaim()`

View File

@@ -4,7 +4,7 @@ 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#L648
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L665
---
# `refreshSession()`

View File

@@ -4,7 +4,7 @@ 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#L689
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L706
---
# `getSession()`

View File

@@ -4,7 +4,7 @@ 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#L704
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L721
---
# `getUser()`

View File

@@ -1,7 +1,7 @@
---
title: 'Serverless Functions'
sidebar_position: 8
image: /img/og/platform/serverless-functions.png
image: /img/og/serverless-functions.png
---
import Tabs from '@theme/Tabs'
@@ -9,7 +9,7 @@ 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.
Serverless functions can be used to handle [event triggers](/database/event-triggers), form submissions, integrations (e.g. Stripe, Slack, etc), and more.
## Creating a Serverless Function
@@ -54,7 +54,7 @@ export default (req, res) => {
## Deploying Serverless Functions
Serverless Functions are automatically deployed using Nhost's [GitHub integration](/platform/github-integration).
Serverless Functions are automatically deployed using Nhost's [Git integration](/platform/git).
All Serverless Functions are deployed with the following options:
@@ -77,12 +77,12 @@ Here's an example of four Serverless Functions with their files and their HTTP e
| `functions/my-company.js` | `https://[project-subdomain].nhost.run/v1/functions/my-company` |
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 f
be turned into HTTP endpoints. This is useful if you have, for example, a utils file (`functions/_utils.js`) or a utils-f
older (`functions/_utils/<utils-files>.js`).
## 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).
[Environment variables](/platform/environment-variables) are available inside your Serverless Functions. Both in production and when running Nhost locally using the [Nhost CLI](/cli).
## Examples
@@ -100,4 +100,4 @@ Serverless Functions are always deployed to the same region as your project.
## Local Debugging
Use `nhost logs functions -f` to see the logs of your Serverless Functions when develop locally with the [Nhost CLI](/platform/cli).
Use `nhost logs functions -f` to see the logs of your Serverless Functions when develop locally with the [Nhost CLI](/cli).

View File

@@ -1,13 +1,13 @@
---
title: 'Storage'
sidebar_position: 7
image: /img/og/platform/storage.png
image: /img/og/storage.png
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Nhost Storage enables you to let your users upload and download files. Nhost Storage is integrated with the [GraphQL API](/platform/graphql) and its permission system from Hasura.
Nhost Storage enables you to let your users upload and download files. Nhost Storage is partially integrated with the [GraphQL API](/graphql), where file metadata and permissions are managed. Files are stored in S3 and served via a CDN.
## Files
@@ -161,6 +161,14 @@ Permissions to upload, download, and delete files are managed through Hasura's p
To upload a file, a user must have the **`insert` permission** to the `storage.files` table. The `id` column must be granted.
The following columns can be used for insert permissions:
- `id`
- `bucket_id`
- `name`
- `size`
- `mime_type`
### Download
To download a file, a user must have the **`select` permission** to the `storage.files` table. **All** columns must be granted.

View File

@@ -95,7 +95,7 @@ const config = {
href: 'https://app.nhost.io',
className: 'header-get-started-link',
position: 'right',
label: 'Get started'
label: 'Dashboard'
}
]
},

View File

@@ -5,8 +5,66 @@ const sidebars = {
defaultSidebar: [
'index',
{
type: 'autogenerated',
dirName: 'platform'
type: 'category',
label: 'Quickstarts',
items: [
{
type: 'autogenerated',
dirName: 'quickstarts'
}
]
},
{
type: 'category',
label: 'Database',
items: [
{
type: 'autogenerated',
dirName: 'database'
}
]
},
{
type: 'category',
label: 'GraphQL API',
items: [
{
type: 'autogenerated',
dirName: 'graphql'
}
]
},
{
type: 'category',
label: 'Authentication',
items: [
{
type: 'autogenerated',
dirName: 'authentication'
}
]
},
'storage',
'serverless-functions',
{
type: 'category',
label: 'CLI',
items: [
{
type: 'autogenerated',
dirName: 'cli'
}
]
},
{
type: 'category',
label: 'Platform',
items: [
{
type: 'autogenerated',
dirName: 'platform'
}
]
}
],
referenceSidebar: [

View File

Before

Width:  |  Height:  |  Size: 296 KiB

After

Width:  |  Height:  |  Size: 296 KiB

View File

Before

Width:  |  Height:  |  Size: 667 KiB

After

Width:  |  Height:  |  Size: 667 KiB

View File

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View File

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View File

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 159 KiB

View File

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 159 KiB

View File

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 155 KiB

View File

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 159 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 161 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 163 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View File

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View File

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

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