8000 GitHub - ryanponce/saaskit: A modern SaaS template built on Fresh.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ryanponce/saaskit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno SaaSKit

Discord Chat CI codecov

Deno SaaSKit is an open-sourced, highly performant template for building your SaaS quickly and easily.

Note: this project is in beta. Design, workflows, and user accounts are subject to change.

Features

Get Started

Get Started Locally

Before starting, you'll need:

  • A GitHub account
  • The Deno CLI and Git installed on your machine

To get started:

  1. Clone this repo:
    git clone https://github.com/denoland/saaskit.git
    cd saaskit
  2. Create a new .env file.
  3. Navigate to GitHub's New OAuth Application page.
  4. Set Application name to your desired application name. E.g. ACME, Inc.
  5. Set Homepage URL to http://localhost:8000.
  6. Set Authorization callback URL to http://localhost:8000/callback.
  7. Click Register application.
  8. Copy the Client ID value to the .env file:
    GITHUB_CLIENT_ID=<GitHub OAuth application client ID>
    
  9. On the same web page, click Generate a new client secret.
  10. Copy the Client secret value to the .env file on a new line:
    GITHUB_CLIENT_SECRET=<GitHub OAuth application client secret>
    
  11. Start the server:
    deno task start
  12. Navigate to http://localhost:8000 to start playing with your new SaaS app.

Set-Up Stripe (Optional)

This guide will enable test Stripe payments, the pricing page, and "Premium user" functionality.

Before starting, you'll need:

To get started:

  1. Navigate to the API keys page on the Developers dashboard.
  2. In the Standard keys section, click Reveal test key on the Secret key table row.
  3. Click to copy the value and paste to the .env file:
    STRIPE_SECRET_KEY=<Stripe secret key>
    
  4. Run the Stripe initialization script:
    deno task init:stripe
  5. Copy the Stripe "Premium Plan" price ID to the .env file:
    STRIPE_PREMIUM_PLAN_PRICE_ID=<Stripe "Premium Plan" price ID>
    
  6. Begin listening locally to Stripe events:
    stripe listen --forward-to localhost:8000/api/stripe-webhooks --events=customer.subscription.created,customer.subscription.deleted
    
  7. Copy the webhook signing secret to the .env file:
    STRIPE_WEBHOOK_SECRET=<Stripe webhook signing secret>
    
  8. Start the server:
    deno task start
  9. Navigate to http://localhost:8000 to start playing with your new SaaS app with Stripe enabled.

Note: You can use Stripe's test credit cards to make test payments while in Stripe's test mode.

Bootstrap the Database (Optional)

Use the following commands to work with your local Deno KV database:

  • deno task db:seed - Populate the database with data from the Hacker News API.
  • deno task db:dump - Print all database values.
  • deno task db:reset - Reset the database. This is not recoverable.

Customization

Global Constants

The utils/constants.ts file includes global values used across various aspects of the codebase. Update these values according to your needs.

Blog

To create a new blog post, create a Markdown (.md) file within /data/posts/ with the filename as the slug. E.g. /data/posts/hello-there.md file will correspond to the /blog/hello-there route. See /data/posts/ for examples.

Post properties are to be added to the starting Front Matter section of the Markdown file. See the Post interface in /utils/posts.ts for a full list of properties and their types.

Themes

You can customize theme options such as spacing, color, etc. By default, Deno SaaSKit comes with primary and secondary colors predefined within twind.config.ts. Change these values to match your desired color scheme.

Deploying to Production

This section assumes that a local development environment has been set up.

Authentication (OAuth)

  1. Change your OAuth app settings to the following:
  • Homepage URL = https://{{ YOUR DOMAIN }}
  • Authorization callback URL = http://{{ YOUR DOMAIN }}/callback

Payments (Stripe)

In order to use Stripe in production, you'll have to activate your Stripe account.

Once your Stripe account is activated, simply grab the production version of the Stripe Secret Key. Th 8776 at will be the value of STRIPE_SECRET_KEY in prod.

Automate Stripe Subscription Updates via Webhooks

Keep your user's customer information up-to-date with billing changes by registering a webhook endpoint in Stripe.

  • Endpoint URL: https://{{ YOUR DOMAIN }}/api/stripe-webhooks
  • Listen to Events on your account
  • Select customer.subscription.created and customer.subscription.deleted

Stripe Production Environmental Variables

  • STRIPE_SECRET_KEY: Dashboard Home (Right Side of Page) -> Secret Key (only revealed once)
  • STRIPE_WEBHOOK_SECRET: Dashboard Home -> Developers (right side of page) -> Create webhook -> Click Add Endpoint
    • After Creation, redirected to new webhook page -> Signing Secret -> Reveal
  • STRIPE_PREMIUM_PLAN_PRICE_ID: Dashboard -> Products -> Premium Tier -> Pricing/API ID

Stripe Customer Portal Branding

Set up your branding on Stripe, as the user will be taken to Stripe's checkout page when they upgrade to a subscription.

Deploy to Deno Deploy

Deploy your SaaS app close to your users at the edge with Deno Deploy:

  1. Clone this repository for your SaaSKit project.
  2. Sign into Deno Deploy with your GitHub account.
  3. Select your GitHub organization or user, repository, and branch.
  4. Select "Automatic" deployment mode and main.ts as the entry point.
  5. Click "Link", which will start the deployment.
  6. Once the deployment is complete, click on "Settings" and add the production environmental variables, then hit "Save".

You should now be able to visit your newly deployed SaaS.

Deploy to any VPS with Docker

Docker makes it easy to deploy and run your Deno app to any virtual private server (VPS). This section will show you how to do that with AWS Lightsail and Digital Ocean.

  1. Install Docker on your machine, which should also install the docker CLI.

  2. Create an account on Docker Hub, a registry for Docker container images.

Note: the Dockerfile, .dockerignore and docker-compose.yml files come included with this repo.

The values of the environmental variables are pulled from the .env file.

The DENO_DEPLOYMENT_ID variable is needed for Docker deployment of a Deno Fresh app for caching to work properly. Its value needs to be a unique id tied to the deployment. We recommend using the SHA1 commit hash, which can be obtained from the following command run in the repo's root folder:

# get the SHA1 commit hash of the current branch
git rev-parse HEAD

Refer to these guides for using Docker to deploy Deno to specific platforms:

Goals and Philosophy

For the user, the website should be fast, secure and have a design with clear intent. Additionally, the HTML should be well-structured and indexable by search engines. The defining metrics for these goals are:

For the developer, the codebase should minimize the steps and amount of time required to get up and running. From there, customization and extension of the web app should be simple. The characteristics of a well-written codebase also apply, such as:

  • Easy to understand
  • Modular functionality
  • Clearly defined behavior with validation through tests

Community and Resources

Join the #saaskit channel in Deno's Discord to meet other SaaSKit developers, ask questions, and get unblocked.

Here's a list of articles, how to guides, and videos about SaaSKit:

About

A modern SaaS template built on Fresh.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.9%
  • Dockerfile 0.1%
0