Skip to content
/ fuse.js Public
forked from StellateHQ/fuse

Fuse.js: The opinionated framework for creating typesafe data layers

License

Notifications You must be signed in to change notification settings

cstrnt/fuse.js

 
 

Repository files navigation

Fuse.js

Fuse.js: End-to-end typesafe data fetching for frontend teams at scale

Getting Started

Before you begin

Before you start using Fuse.js, you need to have:

  • Familiarity with TypeScript
  • A Next.js app*

*Note that a Fuse.js data layer can also be developed and deployed outside of Next.js. However, our current focus is on making the experience with Next.js great, so expect rough edges elsewhere.

Setting up your Fuse.js data layer

When you are in your Next.JS app run the following command, this will install all the packages and generate the files you need.

npm create fuse-app

Next, run npm run dev and... That’s it! Fuse.js will now serve a GraphQL API at /api/fuse.

Querying your data layer

import { graphql } from '@/fuse'
import { execute } from '@/fuse/server'

const UserQuery = graphql(`
  query User($id: ID!) {
    user(id: $id) {
      id
      name
    }
  }
`)

export default async function Page() {
  const result = await execute({
    query: UserQuery,
    variables: { id: '1' },
  })

  return <p>Welcome {result.data?.user?.name}</p>
}

Read the documentation for more information about using Fuse.js.

Quicklinks to some of the most-visited pages:

License

Licensed under the MIT License, Copyright © 2023-present Stellate, Inc.

See LICENSE for more information.

About

Fuse.js: The opinionated framework for creating typesafe data layers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 74.5%
  • MDX 18.6%
  • JavaScript 5.8%
  • SCSS 1.1%