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.
-
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.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.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.
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.
-
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
-
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
MIT © mroll