Skip to content
Syno Package Land
Language: English

Native apps

A native app is a Go backend that DSM runs as a CGI, plus a UI in a DSM window. It installs as an unsigned SPK and runs as its own package account, without containers or root access.

Terminal window
synopkgland init -t native-go my-app

The default UI is Vue; --ui plain writes ui/app.js (UI components), and --with adds capabilities (Capabilities). init never overwrites a file (INIT_TARGET_NOT_EMPTY).

PathWhat it is
dsm-package.yamlIdentity, version, build number, architectures, backend and UI location
backend/internal/app/Routes and handlers
backend/internal/api/permissions.jsonWho may call each method
frontend/src/Vue UI shell; on-screen text in frontend/src/i18n/<locale>.json
i18n/messages/<locale>.jsonPackage text in nine languages
i18n/glossary.jsonDSM’s own words and the messages that must use them
AGENTS.md, CLAUDE.mdInstructions for an AI assistant
backend/internal/api/permissions.go, backend/cmd/Permission loading and CGI/jobs wiring; rarely edited

Request guards, sign-in, File Station, jobs and delegate come from the SDK: the Go module github.com/synopackageland/syno-pkg-land-sdk and @synopackageland/sdk. backend/go.mod and frontend/package.json must name the same SDK version (SDK_VERSION_MISMATCH).

A route is a Go handler in backend/internal/app/routes.go plus an entry in backend/internal/api/permissions.json.

func Routes(cfg Config) []api.Route {
routes := cfg.delegateRoutes()
routes = append(routes, []api.Route{
api.Handle("app.status", cfg.status),
api.Handle("greeting.get", cfg.getGreeting),
api.Handle("greeting.set", cfg.setGreeting),
api.Handle("notes.list", cfg.listNotes),
}...)
// ...the rest of the function stays as generated
}
func (cfg Config) listNotes(_ context.Context, caller api.Caller, params json.RawMessage) (any, error) {
var in struct {
Limit int `json:"limit"`
}
if err := decodeParams(params, &in); err != nil {
return nil, err
}
return map[string]any{"owner": caller.User(), "notes": []string{}}, nil
}
{
"schema": 1,
"default": "administrators",
"methods": {
"notes.list": "authenticated"
}
}

Add valid parameters to sampleParams in backend/internal/app/routes_test.go, such as "notes.list": with {"limit":20}; the generated tests fail until you do. Run (cd backend && go test ./...).

  • A handler is func(ctx, caller, params) (any, error). decodeParams rejects unknown fields; return api.BadRequest(message) or &api.Error{Code, Message}, or the UI sees internal.
  • Use api.HandleRequest for the request, api.HandleResponse for cookies or a written response, and api.HandleStream for a transfer.
  • caller.User() and caller.Admin() come from DSM, never the request; api.RequireAdmin(caller) reserves one action and returns admin_required.
  • Method names are dot-joined lowercase words such as notes.list; every name in permissions.json must be registered. Changing the file needs a rebuild.
Level in permissions.jsonWithout a sessionOrdinary userAdministrator
administrators, and any unlisted methodsession_requiredadmin_requiredruns
authenticatedsession_requiredrunsruns
publicrunsrunsruns

default must stay administrators; public is only for routes that work without signing in (API reference). An authenticated or public route also lets ordinary users open the window; entry and ui.launch change that (see entry and launch mode).

ctx.call(method, params) posts to your backend with the DSM session and resolves with the result; errors reject with { code, message }.

const { notes } = await ctx.call<{ notes: string[] }>('notes.list', { limit: 20 })

Hide administrator-only controls with ctx.user?.isAdmin; the backend still decides. ctx.reopen(fn), ctx.locale, ctx.launchParams and ctx.onLaunch(fn) are described in the API reference.

Replies use HTTP 200; a failure is {"success": false, "error": {"code", "message"}}, as in DSM’s own web API. Codes are in Errors.

Put a page’s route in the route launch parameter:

https://<nas>:5001/?launchApp=SYNO.SDS.<package>.Instance&launchParam=route%3D%252Fa%252Fnotes%252F42

launchParam is encoded twice, for the URL and each value, because DSM decodes it into pairs and then each value. followLaunchRoute follows the opening launch and each later one:

import { followLaunchRoute } from '@synopackageland/sdk'
// Vue Router with createWebHashHistory: #/a/notes/42 in a portal link, route=/a/notes/42 from DSM.
const stop = followLaunchRoute(ctx, (route) => { void router.replace(route) })

The route is a path from the app root: one leading /, no backslash or control character, at most 2048 characters. Launch values are untrusted: pick a page or record with them, never HTML, a URL or a permission.

The app ships in nine languages: en, zh-TW, zh-CN, ja, ko, de, fr, es and it; other DSM languages show English.

  • i18n/messages/<locale>.json holds flat "dotted.key": "text" pairs; en.json is required, and every file needs exactly its keys and {placeholder} names. Add an error.<code> message for every backend error.
  • i18n/glossary.json lists DSM’s words, such as “Save” and “Cancel”, and which messages must contain them; add your key to a term’s keys to use it.
  • i18n.info sets Package Center text per language. In a plain UI, ctx.t("greeting.setBy", { text, user }) reads these files; the Vue UI keeps its text in frontend/src/i18n/<locale>.json.

check and build fail on a missing or extra key, a dropped placeholder, an unsupported language or a glossary mismatch.

A daemon keeps the App running as a supervised foreground process, as the package account, for work that must outlive one request.

  • Resident children and the daemon restart after every unrequested exit, including exit zero and a signal, with jittered exponential backoff. After repeated failures in the retry window the daemon shows failed and the App offers Retry.
  • A requested stop stays stopped: turning the integration off, stopping the package, an upgrade and uninstall never restart it.
  • An explicit start or restart re-arms recovery with the same bounds.

daemon.ingress serves the daemon’s web UI at /synopkgland/<package>/ on DSM’s own address, so the browser sends its DSM cookie and the page stays same-origin:

daemon:
backend: true
ingress:
path: /synopkgland/MyApp/
  • The path is exactly /synopkgland/<package>/, with the manifest’s package ID; every other top-level path is refused at build and by inspect.
  • os_min_ver must be 7.2-64570 or later: DSM 7.1 refuses web-config in an unsigned package.
  • The daemon listens on the socket in SYNOPKGLAND_INGRESS_SOCKET and mounts its routes below SYNOPKGLAND_INGRESS_PATH; nginx only proxies, so the daemon checks DSM sign-in itself.
  • A Go backend serves it with api.ServeIngress, which checks the package ID in the socket. The fixed location block turns buffering off, so server-sent events arrive as they are written.
  • A stopped App’s path returns 404.

daemon.restart is optional and takes off or on-failure with bounded delays, attempts and window; without it the supervisor uses always. The manifest reference lists every field.

Terminal window
synopkgland check
synopkgland build
synopkgland deploy --host my-nas
synopkgland status --host my-nas
synopkgland logs --host my-nas
CommandWhat it does
checkValidates the manifest, capabilities, permissions.json and translations
buildWrites dist/<package>-<version>-<build>-<arch>.spk per architecture; run pnpm install in frontend/ first
deployBuilds and installs one architecture; the version-build must exceed the installed one (DEPLOY_VERSION_INVALID)
statusPackage state, the Open URL, and capability readiness
logsStatus lines and identity, not an application log

--host is required for deploy, status and logs (HOST_REQUIRED). Bump build for every SPK; --json prints one object. See Ship.

Symptom or codeCauseFix
admin_required for an ordinary userThe route is administrators or unlistedSet "authenticated" for it and rebuild
unknown_methodThe method is not registered in routes.goRegister it with api.Handle
bad_requestdecodeParams rejected a field, or the handler rejected a valueSend exactly the fields the handler reads
INIT_TARGET_NOT_EMPTYinit found an existing fileUse an empty directory
ItemLimit
Package name2 to 64 letters and digits, starting with a letter
buildInteger from 1 to 9999
Architecturesx86_64, aarch64, armv7; armv7 is built but not verified for jobs, delegate, root operations and daemon
Minimum DSMos_min_ver defaults to 7.1-42661

Body size and timeout limits are in the API reference.