Coder Social home page Coder Social logo

nextjs-fauna's Introduction

Fauna GraphQL Guestbook Starter

This Guestbook Single-Page Application (SPA) example shows you how to use Fauna's GraphQL endpoint in your Next.js project.

Deploy your own

Deploy the example using Vercel:

Deploy with Vercel

Why Fauna

By importing a .gql or .graphql schema into Fauna (see our sample schema file), Fauna will generate required Indexes and GraphQL resolvers for you -- hands free ๐Ÿ‘ (some limitations exist).

How to use

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example with-fauna with-fauna-app
# or
yarn create next-app --example with-fauna with-fauna-app

You can start with this template using create-next-app or by downloading the repository manually.

To use a live Fauna database, create a database at dashboard.fauna.com and generate an admin token by going to the Security tab on the left and then click New Key. Give the new key a name and select the 'Admin' Role. Copy the token since the setup script will ask for it. Do not use it in the frontend, it has superpowers which you don't want to give to your users.

Setting Up Your Schema

The Next.js and Fauna example includes a setup script (npm run setup). After providing your admin token, the script will:

  • Import your GraphQL schema: Fauna automatically sets up collections and indexes to support your queries. You can view these in your project dashboard under GraphQL.
  • Create an index and function: The script will create a GraphQL resolver that uses User-defined functions based on a sorting index.
  • Create a scoped token: This token is for use on the client side. The admin key can be used on the server side.

After the script completes, a .env.local file will be created for you with the newly generated client token assigned to an Environment Variable.

Run locally

Install packages, set up if needed, then run the development server:

npm install
npm run dev

Your app should be up and running on http://localhost:3000!

nextjs-fauna's People

Contributors

edydkim avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.