How Rough works
Rough empowers your users to build custom features directly inside your app, just by describing what they need. You control where those features can appear and how they can integrate with your data.
Connecting Rough to your app
Connecting Rough starts with three decisions: how to identify your users, what their Features can do, and where those Features appear in your app.
1 Use your app’s sign-in
Your users sign in to your app as usual. When the SDK needs to tell Rough who’s signed in, it calls an endpoint on your server. That endpoint checks the user’s existing session and returns a token (a JWT) that expires within five minutes. It is signed with a key from Rough’s dashboard that never leaves your server. The SDK exchanges it with Rough, so your server never calls Rough directly.
The token carries two IDs. Its subject (sub) is the
user’s ID, and the account ID decides who shares Features. Use a
team or workspace ID if teammates should share Features, or the
user’s own ID if they shouldn’t. Always take both from the
session, never from the request.
app.post('/api/rough/user-token', async (req, res) => {
const { user, team } = req.session
const token = await signRoughToken({
sub: user.id,
rough: {
user: { name: user.name },
account: { id: team.id },
},
})
res.json({ token })
})2 Define what Features can do
A Surface is a place in your app where Features can appear. In your frontend, you define each Surface and the capabilities its Features can use. Queries read data, Subscriptions keep data up to date, and Mutations make changes.
Each capability has typed inputs and outputs and sample data. Rough receives the schemas and samples, not your code, and uses them to build Features. Previews in the Builder run on the samples. Live capabilities run in your frontend and call your API as the signed-in user, so your backend still checks permissions on every read and write.
const surface = defineRoughSurface({
toolList: [
new Mutation({
name: 'Update record',
inputSchema: z.object({
id: z.string(),
name: z.string(),
}),
outputSchema: RecordSchema,
outputSample: sampleRecord,
implementation: (input) => {
return api.records.update(input)
},
}),
],
})3 Choose where Features appear
People create and edit Features in the Builder, which opens inside your app. When someone publishes a Feature, the SDK makes it available on its Surface. Your app controls the layout: Features can appear as cards, in their own tabs, or wherever they fit your interface.
In the React example, usePublishedFeatures and RoughFeature are small wrappers in your code around the SDK’s subscribeToRoughFeatures and mountRoughFeature. Each Feature runs in its own
sandboxed iframe and updates automatically when a new version is
published.
function CustomFeatures() {
const features = usePublishedFeatures(surface)
return features.map((feature) => (
<RoughFeature
featureId={feature.id}
surface={surface}
/>
))
}Behind the scenes
Rough builds the Feature from the user’s request, your capability schemas, and sample data. Users preview it with sample data before deciding whether to publish.
Once published, Rough serves the Feature’s files, but live capability calls go through your app, not Rough’s servers.
User Authentication
- 1
Start the SDK
The SDK requests a signed token from your backend.
- 2
Sign a token
Your API checks the user’s session and returns a short-lived JWT.
- 3
Request published Features
The SDK uses the signed token to connect to Rough and get Features.
- 4
Return published Features
Rough verifies the token and returns published Features for this account.
- 5
Display published Features
Your app shows the Features on this Surface.
Building a Feature
- 1
Define capabilities
One-time setup: define what Features can do, with schemas and sample data.
- 2
Open the Feature Builder
Your app opens the SDK’s Builder for the selected Surface.
- 3
Describe the Feature
The user tells Rough what to build without leaving your app.
- 4
Build the Feature
The agent builds against your capabilities and compiles static files.
- 5
Host the build
Rough stores the compiled files and makes them available for preview.
- 6
Preview the Feature
The user tests with sample data. Preview changes aren’t saved.
- 7
Publish the Feature
The user makes this build the live version of the Feature.
- 8
Display the Feature
Your app shows the published version on the Surface.
Running a Feature
- 1
Serve the published build
Rough serves the Feature’s HTML, JavaScript and CSS.
- 2
Load in an isolated iframe
The Feature can’t read your app’s page, cookies or storage.
- 3
Run your capability code
Your code takes validated inputs and returns a result to the SDK.
- 4
Enforce your permissions
If your code calls your API, your existing access checks still apply.
- 5
Deliver the result
The SDK sends the result back to the Feature in its iframe.
The sandbox protects your app
Each Feature runs behind a security boundary enforced by the browser. Even if its code tries, it can’t read or change your app’s page, read your app’s cookies or browser storage, open pop-ups, or redirect the tab.
You choose which capabilities a Feature can call. Your code handles those calls, and your backend decides what the signed-in user can access or change.
Lara Curtis
- Personal Info
- Job Timeline
- Time Off
People & Culture Manager
Basic Information
- Employee #
- 1005
- First name
- Lara
- Last name
- Curtis
- Preferred language
- English
Employment
- Hire date
- May 6, 2019
- Department
- People & Culture
- Employment type
- Full-time
Office Days
Remix- Mon Home
- Tue Office
- Wed Office
- Thu Home
- Fri Home
Work Location
- Office
- Toronto Head Office
- Work arrangement
- Hybrid
- Office days
- Tue, Wed
Contact
- Work email
- [email protected]
Isolated by the browser. Rough uses a sandboxed iframe without allow-same-origin. The browser gives the Feature
an opaque origin, and its same-origin policy blocks direct access to your app’s page and storage—even if both are
hosted at the same origin. Rough also leaves pop-ups and top-level
navigation disabled in the sandbox.
Features request access through the capabilities you expose, with your backend’s permission checks deciding what the signed-in user can access or change.
Your app stays in control
Features run separately from your app
Each Feature runs in a sandboxed iframe, separate from the rest of your app. It cannot directly read your app’s cookies or browser storage, or inspect and change your page. It interacts with your app through the capabilities you choose to expose.
You own the capabilities
When a Rough Feature calls a capability, the call goes through your app, not Rough’s servers. You control access to your backend and can run capabilities as the signed-in user, using your existing server-side permissions.
Your live data stays in your app
Rough receives limited information to build and manage Features. Live capability data doesn’t pass through Rough’s servers. Our build agent works from your capability schemas and samples—it cannot call your live capabilities.
You own the Feature code
You own the code generated for your Features, including those your customers build, subject to our Terms and third-party licences. Rough hosts the published files your app loads.
Our Infrastructure
- App servers and database
- Oregon, US
- Feature files
- Cloudflare R2
- AI processing
- Your choice of OpenAI or Anthropic
Still have questions?
If something here doesn’t answer how Rough would fit your app, your security review, or your data requirements, get in touch. We’re happy to talk it through.
Contact us