This is a sample NextJS webapp that uses StatelyDB.
NOTE: You MUST set up your StatelyDB store and schema following the instructions below before deploying to Vercel!
- Uses a sample schema that defines the
Profile
andLink
Item types, and related generated typescript types. - Displays a profile page and a collection of links. By default the site is not editable, which you can change by updating the
NEXT_PUBLIC_EDITABLE
environment variable totrue
.
- Node.js 14.x or later
- Vercel account
- Stately Cloud account and access to a StatelyDB Store
-
Clone this repository
-
Install dependencies:
npm install
-
Visit the Stately Cloud console at https://console.stately.cloud and grab your credentials and Store ID. If you don't have one yet, request one.
-
Create a new Vercel site:
vercel link
This command will walk you through "linking" the code you've checked out to a new Vercel site. The deployment will fail because you don't have the required environment variables set, so to save time you may want to cancel the deployment and return to the command line.
-
Configure environment variables using the following commands. For the demo we recommend setting the values to be the same across all environments.
vercel env add NEXT_PUBLIC_EDITABLE vercel env add PROFILE_SLUG vercel env add STATELY_STORE_ID vercel env add STATELY_ACCESS_KEY
See
.env.local.example
for example values.We recommend setting the
PROFILE_SLUG
todefault
. SetNEXT_PUBLIC_EDITABLE
totrue
if you want to make changes to the list of links orfalse
for read-only mode. -
Deploy to Vercel
vercel deploy
- Install the Stately CLI:
curl -sL https://stately.cloud/install | sh
- Log in to your Stately account:
stately login
- Navigate to the
schema
directory:cd schema
- Install dependencies:
npm install
- Publish the schema:
stately schema put -m "my schema change message" --schema-id <your_schema_id> schema.ts
- Generate the TypeScript client:
stately schema generate --language ts --schema-id <your_schema_id> --version <schema_version> ../src/lib/generated
- If you want the site to be editable, set the environment variable
NEXT_PUBLIC_EDITABLE
totrue
. You probably don't want everyone on the Internet to be able to edit your page, so use this with caution -- it's just an example! - If you want to change the profile photo, swap out
thispersondoesnotexist.jpg
for something else.
Run the development server:
vercel dev
Open http://localhost:3000 in your browser to see the application.