| 1 | --- |
| 2 | title: Projects |
| 3 | description: A workspace-scoped namespace containing Services, Environments, Volumes, Variables, and Buckets. |
| 4 | --- |
| 5 | |
| 6 | A [`Railway.Project`](/providers/railway/project) is a workspace-scoped |
| 7 | namespace. It owns environments and services. Names are unique per |
| 8 | workspace. |
| 9 | |
| 10 | ## Create a Project |
| 11 | |
| 12 | Alchemy generates a unique name unless you pass one. |
| 13 | |
| 14 | ```typescript |
| 15 | const site = yield* Railway.Project("Site"); |
| 16 | ``` |
| 17 | |
| 18 | `url` is `https://railway.com/project/{projectId}`. A production |
| 19 | environment is created with the project — do not recreate it as an |
| 20 | [Environment](/railway/compute/environments). `environmentId` is that |
| 21 | primary environment. |
| 22 | |
| 23 | Nothing answers on the public internet until a |
| 24 | [Service](/railway/compute/services) is deployed. The Service gets its |
| 25 | own `*.up.railway.app` hostname. |
| 26 | |
| 27 | :::note |
| 28 | Prefer omitting `name` in tests and CI so names stay unique and |
| 29 | reclaimable. |
| 30 | ::: |
| 31 | |
| 32 | ## A stable name |
| 33 | |
| 34 | Pass `name` when you need a stable project name. |
| 35 | |
| 36 | ```typescript |
| 37 | const site = yield* Railway.Project("Site", { |
| 38 | name: "my-site", |
| 39 | }); |
| 40 | ``` |
| 41 | |
| 42 | Changing `name` later updates the project in place. |
| 43 | |
| 44 | ## Description |
| 45 | |
| 46 | `description` is optional and updates in place. |
| 47 | |
| 48 | ```typescript |
| 49 | const site = yield* Railway.Project("Site", { |
| 50 | description: "production web app", |
| 51 | }); |
| 52 | ``` |
| 53 | |
| 54 | ## Workspace |
| 55 | |
| 56 | Workspace defaults to the current token |
| 57 | (`me.workspace ?? me.workspaces[0]`). Pass `workspaceId` to pin it. |
| 58 | |
| 59 | ```diff lang="typescript" |
| 60 | const site = yield* Railway.Project("Site", { |
| 61 | name: "my-site", |
| 62 | + workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", |
| 63 | }); |
| 64 | ``` |
| 65 | |
| 66 | :::caution[Changing `workspaceId` replaces the Project] |
| 67 | The Project is created in the new workspace. The old Project is |
| 68 | deleted. |
| 69 | ::: |
| 70 | |
| 71 | ## Default environment name |
| 72 | |
| 73 | `defaultEnvironmentName` is create-only. Railway's default is |
| 74 | `production`. Extra environments (staging) are a separate |
| 75 | [Environment](/railway/compute/environments) resource. |
| 76 | |
| 77 | ```typescript |
| 78 | const site = yield* Railway.Project("Site", { |
| 79 | defaultEnvironmentName: "production", |
| 80 | }); |
| 81 | ``` |
| 82 | |
| 83 | ## Module-scope declarations |
| 84 | |
| 85 | Declare the Project once. Pass it into every child. |
| 86 | |
| 87 | ```typescript |
| 88 | // src/project.ts |
| 89 | import * as Railway from "alchemy/Railway"; |
| 90 | |
| 91 | export const Site = Railway.Project("Site"); |
| 92 | ``` |
| 93 | |
| 94 | Resource-valued props accept the resource or an Effect producing |
| 95 | it. Do not unwrap it just to pass it along. |
| 96 | |
| 97 | ## Destroy |
| 98 | |
| 99 | `alchemy destroy` deletes children, then the Project. |
| 100 | |
| 101 | ## Where next |
| 102 | |
| 103 | The [tutorial](/railway/tutorial/part-1) deploys a Project from an |
| 104 | empty directory. [Services](/railway/compute/services) run in the |
| 105 | Project. [Environments](/railway/compute/environments) add staging. |
| 106 | The [`Project` reference](/providers/railway/project) lists every |
| 107 | prop. |
| 108 | [Example: railway-project](https://github.com/alchemy-run/alchemy/tree/main/examples/railway-project) |
| 109 | is a Project plus an image Service. |