@staqjs/server v0.0.8
staq
Staq is a Javascript library for creating Software-as-a-Service (SaaS) businesses.
The staq
package contains a set of React components that implement standard SaaS features including:
- User accounts
- Landing page
- Pricing page
- Subscription management (via Stripe Customer Portal)
The package also ships with a set of NodeJS functions to be used with Google Firebase to implement the backend logic necessary for features like subscription billing with Stripe.
Quickstart
Install
yarn add staq
Initialize and configure
In your
index.js
, add the following import:import { initStaq, withStaq } from staq
Call
initStaq
and pass in a configuration object specifying the name of your site and your Firebase config object.initStaq({ siteTitle: 'Test App', landingPageHeader: 'SaaS apps are great', landingPageSubheader: 'You should totally subscribe', firebaseConfig: { // your firebase config } })
Also in
index.js
, wrap your app inwithStaq
Take the first argument toReactDOM.render
and pass it to thewithStaq
function.```jsx ReactDOM.render( withStaq(<App />), document.getElementById('root') ) ```
Use
staq
to install standard SaaS features In yourApp.js[x]
, importStaqRoutes
and render them inside your router.```jsx import React from 'react' import { BrowserRouter as Router } from 'react-router-dom' import { StaqRoutes } from 'staq' function App(props) { return ( <Router> <StaqRoutes /> </Router> ) } export default App ```
Test out the routes
Run
yarn start
and head tohttp://localhost:3000
to see your landing page generated courtesy ofstaq
. You should see something like this.
Contributor Guide
Here's how to set staq
up locally to hack on it.
Clone the repo.
$ git clone git@github.com/staqjs/staq
Create a fresh React project. Let's call it
staq-dev
.$ npx create-react-app staq-dev
Create a fresh Firebase project. Here are some more details.
Register your clone of
staq
withnpm link
$ cd /path/to/staq/clone $ npm link
Link your clone of
staq
to the new React project$ cd /path/to/staq-dev $ npm link staq
Link the new project's React to your clone of
staq
. (Assuming your clone ofstaq
andstaq-dev
are siblings in the file tree.)$ cd /path/to/staq/clone $ npm link ../staq-dev/node_modules/react
Follow the Quickstart steps to install
staq
to the newstaq-dev
project.In one terminal, start a file watcher in your
staq
clone that will recompile with any changes.$ cd /path/to/staq/clone $ yarn start
In another terminal, start up
staq-dev
.$ cd /path/to/staq-dev $ yarn start
Create a Firebase Project
Head over to the Firebase Console.
Click Add Project
Follow the steps to create the project.
On the left side bar of the project dashboard, click Authentication.
On the Authentication page, go to the Sign-in Method tab and enable Email/Password sign-in.
On the left side bar, click Database. Create a Firestore database.
All done!
License
MIT © mroll