https://github.com/sst/monorepo-template
SST v3 monorepo template
https://github.com/sst/monorepo-template
monorepo sst
Last synced: 21 days ago
JSON representation
SST v3 monorepo template
- Host: GitHub
- URL: https://github.com/sst/monorepo-template
- Owner: sst
- License: mit
- Created: 2024-07-19T17:52:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-23T20:04:47.000Z (8 months ago)
- Last Synced: 2025-06-08T01:11:05.419Z (4 months ago)
- Topics: monorepo, sst
- Language: TypeScript
- Homepage: https://sst.dev/docs/set-up-a-monorepo
- Size: 23.4 KB
- Stars: 90
- Watchers: 6
- Forks: 20
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Monorepo Template
A template to create a monorepo SST v3 project. [Learn more](https://sst.dev/docs/set-up-a-monorepo).
## Get started
1. Use this template to [create your own repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
2. Clone the new repo.
```bash
git clone MY_APP
cd MY_APP
```3. Rename the files in the project to the name of your app.
```bash
npx replace-in-file '/monorepo-template/g' 'MY_APP' '**/*.*' --verbose
```4. Deploy!
```bash
npm install
npx sst deploy
```5. Optionally, enable [_git push to deploy_](https://sst.dev/docs/console/#autodeploy).
## Usage
This template uses [npm Workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces). It has 3 packages to start with and you can add more it.
1. `core/`
This is for any shared code. It's defined as modules. For example, there's the `Example` module.
```ts
export module Example {
export function hello() {
return "Hello, world!";
}
}
```That you can use across other packages using.
```ts
import { Example } from "@aws-monorepo/core/example";Example.hello();
```We also have [Vitest](https://vitest.dev/) configured for testing this package with the `sst shell` CLI.
```bash
npm test
```2. `functions/`
This is for your Lambda functions and it uses the `core` package as a local dependency.
3. `scripts/`
This is for any scripts that you can run on your SST app using the `sst shell` CLI and [`tsx`](https://www.npmjs.com/package/tsx). For example, you can run the example script using:
```bash
npm run shell src/example.ts
```### Infrastructure
The `infra/` directory allows you to logically split the infrastructure of your app into separate files. This can be helpful as your app grows.
In the template, we have an `api.ts`, and `storage.ts`. These export the created resources. And are imported in the `sst.config.ts`.
---
**Join our community** [Discord](https://sst.dev/discord) | [YouTube](https://www.youtube.com/c/sst-dev) | [X.com](https://x.com/SST_dev)