Giter Site home page Giter Site logo

mocktailengineer / sveltefire Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codediodeio/sveltefire

0.0 0.0 0.0 980 KB

Cybernetically enhanced Firebase apps

License: MIT License

JavaScript 4.56% TypeScript 50.07% HTML 0.90% Svelte 44.47%

sveltefire's Introduction

SvelteFire

npm Discord License
Cybernetically Enhanced Firebase Apps

A minimal, yet powerful library that puts realtime Firebase data into Svelte stores.

Build Complex Apps Faster

SvelteFire allows you to access Firebase Auth, Firestore, Storage, RealtimeDB, and Analytics with minimal complexity. It simplfies relational data with a declarative syntax, handles loading states, automatically disposes of realtime data subscriptions, and more!

Gaze in awe at the example below where we fetch multiple levels of realtime user data with just a few lines of Svelte code:

<!-- 1. ๐Ÿ”ฅ Firebase App -->
<FirebaseApp {auth} {firestore}>

  <!-- 2. ๐Ÿ‘ค Get the current user -->
  <SignedIn let:user>

    <p>Howdy, {user.uid}</p>

    <!-- 3 (a). ๐Ÿ“œ Get a Firestore document owned by a user -->
    <Doc ref={`posts/${user.uid}`} let:data={post} let:ref={postRef}>

      <h2>{post.title}</h2>

      <!-- 4 (a). ๐Ÿ’ฌ Get all the comments in its subcollection -->
      <Collection ref={postRef.path + '/comments'} let:data={comments}>
        {#each comments as comment}

        {/each}
...

Each component in this example above is underpinned by a Svelte store. These custom stores can be used for fine-grained control and to implement your own custom patterns.

Use stores to access Firebase data with Svelte's reactive $ syntax:

<script>
    import { docStore } from 'sveltefire';
    import { firestore } from '$lib/firebase'; // your firestore instance

    const post = docStore(firestore, 'posts/id');
</script>

{$post?.title}

sveltefire's People

Contributors

codediodeio avatar itsalexousd avatar jeremyvoisin avatar kollpotato avatar syed-sheharyar avatar trickypr avatar notunderctrl avatar hectorwithc avatar mxschmitt avatar joulev avatar tk2217 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.