• Stars
    star
    1,195
  • Rank 39,145 (Top 0.8 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 1 year ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A modern SaaS template built on Fresh.

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

Want to know where Deno SaaSKit is headed? Check out our roadmap.

Getting Started Locally

Prerequisites

Setup the repo

  1. Clone the repo:

    git clone https://github.com/denoland/saaskit.git
    cd saaskit
  2. Create a .env file to store environmental variables:

    cp .example.env .env
    

Auth (OAuth)

  1. Register a new GitHub OAuth application with the following values:

    • Application name = a name of your own choosing
    • Homepage URL = http://localhost:8000
    • Authorization callback URL = http://localhost:8000/callback
  2. Once registered, copy the Client ID value to the GITHUB_CLIENT_ID value in your .env file.

  3. Click Generate a new client secret and copy the resulting client secret to the GITHUB_CLIENT_SECRET environment variable in your .env file.

Payments and Subscriptions using Stripe (optional)

Note: Stripe is only enabled if the STRIPE_SECRET_KEY environment variable is set.

  1. Copy your Stripe secret key as STRIPE_SECRET_KEY into your .env file. We recommend using the test key for your development environment.
  2. Run deno task init:stripe and follow the instructions. This automatically creates your "Premium tier" product and configures the Stripe customer portal.

    Note: go to tools/init_stripe.ts if you'd like to learn more about how the init:stripe task works.

  3. Listen locally to Stripe events:
    stripe listen --forward-to localhost:8000/api/stripe-webhooks --events=customer.subscription.created,customer.subscription.deleted
    
  4. Copy the webhook signing secret to .env as STRIPE_WEBHOOK_SECRET.

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

Running the Server

Finally, start the server by running:

deno task start

Go to http://localhost:8000 to begin playing with your new SaaS app.

Bootstrapping your local Database (Optional)

If the home page is feeling a little empty, run

deno task db:seed

On execution, this script will fetch 20 (customizable) of the top HN posts using the HackerNews API to populate your home page.

To see all the values in your local Deno KV database, run

deno task db:dump

And all kv pairs will be logged to stdout

To reset your Deno KV database, run

deno task db:reset

Since this operation is not recoverable, you will be prompted to confirm deletion before proceeding.

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. That 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.

Using Docker to Deploy to any VPS

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.

Setting up Docker

  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

Automatic Deployment with Deno Deploy

These steps show you how to 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 be able to visit your newly deployed SaaS.

Deno Deploy via GitHub Action

You can also choose to deploy to Deno Deploy via a GitHub Action, which offers more flexibility. For instance, with the GitHub Action, you could:

  • Add a build step
  • Run deno lint to lint your code
  • Run deno test to run automated unit tests
  1. Create a new, empty project from the Deno Deploy dashboard. Set a name for your project.

  2. Add the GitHub Action.

    GitHub Actions are configured using a .yml file placed in the .github/workflows folder of your repo. Here's an example .yml file to deploy to Deno Deploy. Be sure to update the YOUR_DENO_DEPLOY_PROJECT_NAME with one that you've set in Deno Deploy.

    # Github action to deploy this project to Deno Deploy
    name: Deploy
    on: [push]
    
    jobs:
      deploy:
        name: Deploy
        runs-on: ubuntu-latest
        permissions:
          id-token: write  # Needed for auth with Deno Deploy
          contents: read  # Needed to clone the repository
    
        steps:
          - name: Clone repository
            uses: actions/checkout@v3
    
          - name: Install Deno
            uses: denoland/setup-deno@main
            # If you need to install a specific Deno version
            # with:
            #   deno-version: 1.32.4
    
    ## You would put your building, linting, testing and other CI/CD steps here
    
    ## Finally, deploy
          - name: Upload to Deno Deploy
            uses: denoland/deployctl@v1
            with:
              project: YOUR_DENO_DEPLOY_PROJECT_NAME
              entrypoint: main.ts
              # root: dist
              import-map: import_map.json
              exclude: .git/** .gitignore .vscode/** .github/** README.md .env .example.env
  3. Commit and push your code to GitHub. This should trigger the GitHub Action. When the action successfully completes, your app should be available on Deno Deploy.

Deploying to Amazon Lightsail with Docker

In order to deploy your Docker image to Amazon Lightsail you need to create an AWS account if you don’t already have one.

  1. The deployment process starts with a local Docker image build which requires that the Dockerfile and docker-compose.yml have been created as above:

    docker compose -f docker-compose.yml build
  2. Tag your image locally using the following command:

    docker tag deno-image {{ username }}/deno-saaskit-aws

    The name deno-image comes from your docker-compose.yml file.

  3. The tagged image needs to be registered on Docker Hub. In order to do that, sign into your Hub account (or create one if you don’t have one).

  4. Push the tagged image to Docker Hub. We have chosen the name deno-saaskit-aws which you can change. Substitute {{username}} with your Docker Hub username.

    docker push {{ username }}/deno-saaskit-aws

    You should then be able to see your image on Docker Hub where it can be picked up by the AWS container service.

  5. Go to the AWS LIghtsail Create a Container Service landing page. On that page you can choose a server location and service capacity or keep the defaults.

    • Click on “Setup deployment” and choose “Specify a custom deployment” which will result in the display of a form. Here’s what you need to fill out:

      • Container name: Give it a name of your choosing.
      • Image: Use the Docker Hub name {{username}}/deno-saaskit-aws.
      • Open Ports: Click “Add open ports” and then enter “8000” as the port.
      • Environmental Variables: Enter the name and values of all production environmental variables from .env.
      • Public Endpoint: Select the container name you just entered.

    Under “Identify your service”, enter a container service name of your choosing. It will become part of the app's domain.

  6. Click the “Create Container Service” button. It will take some time for the deployment to complete. You will see a "Deployed” message when it is finished.

After the deployment is complete, click on the public address link and you'll see your app running in the browser.

Deploying to Digital Ocean with Docker

To deploy your image to Digital Ocean, you will need A Digital Ocean account and the doctl CLI installed and validated locally.

  1. Build the Docker image locally and tag it for a Digital Ocean Container Registry. This requires that you have created Dockerfile and docker-compose.yml files as instructed above

    # Local Docker build
    docker compose -f docker-compose.yml build
    # Tag for DO container registry (separate from Docker Hub)
    docker tag deno-image registry.digitalocean.com/deno-saaskit/deno-image:new
  2. Push your tagged image to your DO container registry.

    doctl registry login -t {{ API Access Token }}
    • Create a Digital Ocean Container Registry named deno-saaskit:
    doctl registry create deno-saaskit

    Alternatively, you can create the container registry online.

    • Push the image to Digital Ocean’s registry (make sure you are logged in using doctl registry login).
    docker push registry.digitalocean.com/deno-saaskit/deno-image:new

    You should now be able to see your image in the DO Container Registry.

  3. Once the deno-image has been pushed to the Digital Ocean registry we can run it in a Digital Ocean Droplet. Go to your Digital Ocean project page and click the 'Create' button and select 'Droplets'.

  4. When the droplet is created, use the console link on your droplet page to SSH to the droplet VM or use SSH locally run this command:

    docker run -d --restart always -it -p 8000:8000 --name deno-image registry.digitalocean.com/deno-on-digital-ocean/deno-image:new

The URL will be visible once the command completes. Use the droplet's IP address with port 8000 to browse to your application deployed on Digital Ocean.

Contributing

When submitting a pull request, please follow the Deno Style Guide.

Before submitting, run the following to check the formatting, linting, licenses, and types and run tests in one hit:

deno task ok

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:

More Repositories

1

deno

A modern runtime for JavaScript and TypeScript.
Rust
93,907
star
2

fresh

The next-gen web framework.
TypeScript
12,234
star
3

rusty_v8

Rust bindings for the V8 JavaScript engine
Rust
3,094
star
4

deno_std

Deno standard library
TypeScript
2,705
star
5

deno_lint

Blazing fast linter for JavaScript and TypeScript written in Rust
Rust
1,514
star
6

vscode_deno

Visual Studio Code plugin for Deno
TypeScript
1,468
star
7

dnt

Deno to npm package build tool.
Rust
1,211
star
8

dotland

[Archived] deno.land website
TypeScript
958
star
9

deno_install

Deno Binary Installer
PowerShell
945
star
10

deno_docker

Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu
Dockerfile
876
star
11

fastwebsockets

A fast RFC6455 WebSocket implementation
Rust
837
star
12

deno-lambda

A deno runtime for AWS Lambda. Deploy deno via docker, SAM, serverless, or bundle it yourself.
TypeScript
836
star
13

deno_blog

Minimal boilerplate blogging.
TypeScript
459
star
14

denokv

A self-hosted backend for Deno KV
TypeScript
456
star
15

deployctl

Command line tool for Deno Deploy
TypeScript
331
star
16

showcase_chat

TypeScript
302
star
17

roll-your-own-javascript-runtime

Rust
298
star
18

merch

The Deno shop!
TypeScript
283
star
19

deno_bindgen

Write high-level Deno FFI libraries in Rust.
Rust
275
star
20

wasmbuild

Build tool to use Rust code in Deno and the browser.
TypeScript
263
star
21

deno_core

The core engine at the heart of Deno
Rust
262
star
22

deno_doc

Documentation generator for Deno
Rust
251
star
23

setup-deno

Set up your GitHub Actions workflow with a specific version of Deno
JavaScript
248
star
24

meet-me

A calendly clone in Deno and hosted on Deno Deploy
TypeScript
245
star
25

deno_kv_oauth

High-level OAuth 2.0 powered by Deno KV.
TypeScript
245
star
26

eszip

A compact file format to losslessly serialize an ECMAScript module graph into a single file
Rust
220
star
27

deno-gfm

Server-side GitHub Flavored Markdown rendering for Deno
TypeScript
220
star
28

deno_emit

Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy
TypeScript
217
star
29

webgpu-examples

TypeScript
214
star
30

doc_website

Archived. New version at https://github.com/denoland/docland
TypeScript
195
star
31

manual

Deprecated - find these resources on docs.deno.com instead
TypeScript
162
star
32

node_shims

npm packages providing shims for the Deno namespace and other globals. Useful for running Deno-first programs on Node.
TypeScript
149
star
33

deno_ast

Source text parsing, lexing, and AST related functionality for Deno
Rust
148
star
34

denobyexample

[Archived] Deno by example - short examples showcasing how to use Deno. Now the examples have been moved to https://github.com/denoland/deno-docs / https://docs.deno.com/examples
TypeScript
146
star
35

fresh_charts

A server-side-rendered charting library for Fresh
TypeScript
136
star
36

deploy_examples

Examples for Deno Deploy
TypeScript
125
star
37

docland

The documentation generation website for Deno
TypeScript
120
star
38

deno_graph

The module graph logic for Deno CLI
Rust
111
star
39

deno_task_shell

Cross-platform shell for deno task.
Rust
104
star
40

deno_registry2

The backend for the deno.land/x service
TypeScript
92
star
41

showcase_todo

Collaborative todo-list app built with Deno and Fresh
TypeScript
82
star
42

deno_third_party

TypeScript
78
star
43

monch

Inspired by nom, but specifically for strings.
Rust
77
star
44

examples

A simple todo app using Deno and React.
TypeScript
77
star
45

tic-tac-toe

A global, real-time multiplayer TicTacToe game for Deno 🦕
TypeScript
75
star
46

deploy_feedback

For reporting issues with Deno Deploy
74
star
47

deno-astro-adapter

A Deno adapter for running Astro applications on the Deno runtime.
TypeScript
67
star
48

pixelpage

Pixel page is an r/place style shared pixel art canvas 🎨🦕
TypeScript
64
star
49

v8

floating patches for rusty_v8
TypeScript
60
star
50

rust-urlpattern

Rust implementation of the `URLPattern` web API
Rust
58
star
51

docs

Deno documentation, examples and API Reference. Powered by Lume.
TypeScript
57
star
52

fresh-wordpress-themes

https://wp-blog-example.deno.dev/ https://wp-sweets-co.deno.dev/
TypeScript
53
star
53

apiland

The API server for deno.land
TypeScript
52
star
54

deno-astro-template

Template repo for an Astro site, preconfigured to run with Deno and Deno Deploy
Astro
49
star
55

sui

Embed custom RO data into precompiled executables
Rust
47
star
56

wanted_modules

Is there a missing deno module that is preventing you from building something? Let us know here.
46
star
57

cargo_gn

Cargo GN integration
Rust
40
star
58

wasmbuild_example

Example of using wasmbuild.
JavaScript
38
star
59

deno_cache_dir

Deno CLI's module cache
Rust
38
star
60

ga

Utilities for server side processing of Google Analytics in Deno CLI and Deploy
TypeScript
38
star
61

serde_v8

Moved to https://github.com/denoland/deno
Rust
36
star
62

import_map

An implementation of WICG Import Maps specification
Rust
30
star
63

flaky_test

atttribute macro for running a flaky test multiple times
Rust
30
star
64

chromium_build

Deno floats patches to //build here (they will be sent upstream eventually)
Python
29
star
65

fresh-blog-example

An example for building a blog with Fresh.
TypeScript
28
star
66

libffi-rs

Fork of libffi-rs which corrects autotools usage
C
22
star
67

deno_npm

npm registry client and dependency resolver used in the Deno CLI.
Rust
22
star
68

deno-sveltekit-template

A starter template for running SvelteKit on Deno Deploy
JavaScript
22
star
69

chatspace

Real-time, collaborative GPT frontend built with Deno KV
TypeScript
22
star
70

doc_components

A set of components for rendering deno_doc doc nodes
TypeScript
21
star
71

rustls-tokio-stream

AsyncRead/AsyncWrite interface for rustls-on-Tokio
Rust
21
star
72

subhosting_ide_starter

Basic starter app for a browser-based IDE using the Deno Subhosting API
JavaScript
21
star
73

deno-vue-example

An example of using Vue with Deno.
Vue
20
star
74

terraform-deploy-provider

Terraform provider for Deno Deploy
Go
20
star
75

deploy_lume_example

An example demonstrating using static site generators on Deno Deploy
TypeScript
20
star
76

monaco-nextjs-demo

A demo Next.js app that features an in-browser IDE built with Monaco.
JavaScript
20
star
77

image-resizing-api

A simple image resizing API written in Deno.
TypeScript
19
star
78

kv_api

WORK IN PROGRESS: Attach a flexible REST API to your Deno web app to manage data in Deno KV
TypeScript
19
star
79

deno-kv-hackathon

Rules, details, and place to submit your project for the Deno KV hackathon.
18
star
80

automation

Automation scripts used for denoland org repos
TypeScript
17
star
81

react18-with-deno

A starter app and tutorial with React18 and Deno.
TypeScript
17
star
82

chromium_buildtools

forked from chromium to use git submodules instead of gclient
Python
17
star
83

benchmark_data

TypeScript
16
star
84

terraform-provider-deno

Terraform provider for hosted Deno APIs
Go
15
star
85

deno-nuxt-template

A template repo for a Nuxt project preconfigured for Deno Deploy
TypeScript
14
star
86

fresh-deno-kv-oauth-demo

Fresh + Deno KV OAuth demo
TypeScript
14
star
87

x-to-jsr

TypeScript
14
star
88

serverless-coldstart-benchmarks

Configuration, benchmarking scripts, and raw data for serverless cold start benchmarks.
Jupyter Notebook
14
star
89

icu

For floating patches on top of https://chromium.googlesource.com/chromium/deps/icu.git
C++
12
star
90

fresh_template

template repository for a Fresh project
12
star
91

deno-vite-plugin

Vite plugin to enable Deno resolution inside vite.
TypeScript
12
star
92

experimental-deno-specifiers-example

TypeScript
12
star
93

deno_lockfile

Rust
12
star
94

fresh-auth-example

TypeScript
11
star
95

deno_config

Rust
11
star
96

deno_media_type

Media type used in Deno.
Rust
11
star
97

notebook

TypeScript
10
star
98

nextgen-install

HCL
10
star
99

v8_valueserializer

A Rust implementation of V8's ValueSerializer and ValueDeserializer
Rust
10
star
100

website_feedback

For reporting issues & suggestions for deno.com and deno.land
9
star