Squizzy is a real-time quiz game powered by Sanity.io.
- Create quizes and host matches with Sanity Studio
- Real-time web app built with Vue, optimized for mobile
- Unsplash integration to easily add photos
- Easy deployment on ZEIT’s Now
Table of contents:
To get started with Squizzy, follow these instructions.
- Copy this repository and clone it to your computer
- Install dependencies with
npm install
(oryarn
) in the root and/studio
folders. - Install Now CLI and Sanity CLI:
npm install --global @sanity/cli now
- Run
sanity init
inside the/studio
folder. Follow the instructions to connect the studio up with a new project and dataset. - Run
sanity deploy
to build and upload the studio to<your-studio-name>.sanity.studio
- Run
sanity deploy
again whenever you want to upload changes to the studio code
- First you need to add a secret token with write permissions to your Now account:
- Find your project’s API settings on https://manage.sanity.io/{YOUR_PROJECTID}/settings/api (or run
sanity manage
inside/studio
) - Under the Tokens sections, create a new token with write permissions
- Rename the
.env.template
file to.env
in the root folder, it will be ignored by git. - Copy-paste the token into the
.env
file for theSQUIZZY_WRITE_TOKEN=
variable - Make sure you have copied the token and run
now secrets add squizzy_write_token $(pbpaste)
to add it on Now. - Alternatively:
now secrets add squizzy_write_token <the-token>
(put a space beforenow
to avoid the token going into your bash history).
- Find your project’s API settings on https://manage.sanity.io/{YOUR_PROJECTID}/settings/api (or run
- Replace the
projectId
anddataset
in./sanityClientConfig.js
with the one you connected the Studio to. Find them by looking in/studio/sanity.json
or by runningsanity debug
in the/studio
folder. - Run
now
in the root folder to deploy the app, or go to your Now account and add the GitHub repository - Add your app domain to your Sanity project’s CORS settings. In the
/studio
folder, runsanity cors add https://your-name.now.sh --no-credentials
or go to your project’s API settings on manage.sanity.io - Update the
remoteWebHost
in/studio/quizConfig
to match your new URL on Now.
Squizzy comes with the following routes:
- Participants can join the game on https://the-app-name.now.sh
- You manage the quizzes on https://the-app-name.now.sh/studio
- You start games on https://the-app-name.now.sh/studio/quiz-match
- The serverless functions will run on https://the-app-name.now.sh/api/function-name
To make a new quiz, go to your studio, click “Quiz” and creat new. Give it a name, description, and some questions with multiple choice answers. The time limit will default to 20 seconds, but you can override it. You can also add an image.
To launch a new game, click Match (/studio/desk/match
) and create new. The slug will be created automatically, and you can select from all your published quizes. When you have selected a quiz, publish the match.
Now you can click the Let’s play button in the studio’s top bar. Here you get an overview over all published and ongoing matches. Select the one you just published to initiate the host screen.
The host screen will show a QR code. Your players can join by scanning this QR code by going to where your Squizzy instance is deployed (https://the-app-name.now.sh), allow camera access, and scan the QR-code. If they aren't able to scan the QR code, they can go to https://the-app-name.now.sh/match/the-game-slug to join.
The host controls the game play from the “Let’s play” tool in the studio.
Go to sanity.io/docs to find more documentation on how to configure and customize Sanity Studio.
- Make sure you have the CLI installed:
npm i -g @sanity/cli
(oryarn global @sanity/cli
) - Inside the
/studio
folder, install dependencies withsanity install
npm run dev
to start the local development server- You can open the studio on localhost:3333
You'll find the content model for the quiz, match, and players inside of /studio/schemas
.
You'll find the host play display inside of /studio/plugins/quiz-match
.
You can tweak the Studio’s color scheme in /studio/squizzyTheme.css
Go to vuejs.org/docs for documentation on Vue.
- Install dependencies by running
npm i
(oryarn
) in the root folder - Run
now dev
to start the web app, the studio, and serverless functions concurrently (remember to install studio dependencies first) - You can access the following endpoints:
- Web app on
localhost:3000
- Serverless functions on
localhost:3000/api/<function-name>
- Sanity Studio on
localhost:3333
- Web app on
N.B! The web app will run on localhost:3000
(the dev server log will show a different port number, but now dev
binds this random port to :3000).
- Add the Giphy asset source selector if you want easy access to animated GIFs for your quizzes.
* You can also use npx @sanity/cli <command>
and npx now <command>
if you prefer not to install global dependencies.