Tutorial Intro
Let's discover Nym in less than 5 minutes.
Getting Started
Get started by creating a new site.
Or try Nym immediately by joining a server with nymhq.com/join.
What you'll need
- Node.js version 16.14 or above:
- When installing Node.js, you are recommended to check all checkboxes related to dependencies.
App Domain structure
The system will consist of 3 different apps hosted separately.
Admin site
Administrative app to manage your admin account and registered site(s).
(e.g: https://app.nymhq.com)
Site setup & Mult-tenant
Next, set up your site: (e.g: https://{user-subdomain}.nymhq.com or any parked domain)
This is for registered users and sites to show contents and manage contents.
Hello World!
Configure your environment
Environment values (.env)
NODE_ENV(production|development)VERCEL_ENV(production|preview|development) Set automaticallyNEXT_PUBLIC_VERCEL_ENV(production|preview|development) Set automaticallyVERCEL_URL(https://{nym-xyz}.vercel.app) Set automaticallyNEXT_PUBLIC_VERCEL_URL(https://{nym-xyz}.vercel.app) Set automaticallyPUBLIC_URL(https://nymhq.com)
Fathom
NEXT_PUBLIC_FATHOM_SITE_IDNEXT_PUBLIC_FATHOM_CUSTOM_URL(https://analytics.example.com)NEXT_PUBLIC_FATHOM_CUSTOM_DOMAIN(analytics.example.com)
CloudFlare
CLOUDFLARE_ACCOUNT_IDCLOUDFLARE_IMAGES_KEY
GraphCDN
GRAPHCDN_PURGE_KEYGRAPHCDN_PURGE_ENDPOINT(https://api.graphcdn.io/purge)
PostMark
POSTMARK_CLIENT_ID
Revue
REVUE_API_KEYHN_TOKEN
Prisma and PlanetScale
A good resource to understand Prisma and its Shadow DB
https://www.prisma.io/docs/concepts/components/prisma-migrate/shadow-database
https://blog.tericcabrel.com/understand-the-shadow-database-feature-prisma/
DATABASE_URL(mysql://user:password@host:port/database)SHADOW_DATABASE_URL(Only required for local env where we run migration commands)
NextAuth.js
NEXTAUTH_URL(https://nymhq.com)NEXTAUTH_SECRETJWT_SIGNING_KEYGITHUB_IDGITHUB_SECRETTWITTER_API_KEYUse Twitter API KeyTWITTER_API_SECRETUse Twitter API Secret
Setting up DB for development environment
Using PlanetScale
- Login to https://app.planetscale.com/
- Create a DB.
- Copy the connection string for the DB, and set it to the .env file variables. (See PlanetScale Doc)
- Run migration
yarn prisma migrate dev
Migrating DB (PScale and Prisma)
During Development
- Edit
prisma/schema.prisma - Format the schema doc
yarn prisma format
- Migrate dev db
# Check the changes in the current schema (prisma/schema.prisma)
# and generate migration file, push to DB.
yarn prisma migrate dev
For Production Deployment
- On PlanetScale, Configure
mainbranch as a production branch - Create a
devbranch frommainbranch - Make sure you connect to the
devbranch only, not to themainbranch directly. - When you want to deploy changes from
devtomain, go to https://app.planetscale.com/sov-ventures/nymhq/deploy-requests and create deployment request fromdevbranch tomainbranch.
Running the development server
cd my-website
yarn start
The cd command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there.
The yarn start command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.